7a9b6735b14fed36577dc1608800260f6b251e81
[doc.git] / tools / checkdocs.sh
1 #!/bin/bash
2 #set -x # uncomment for bash script debugging
3
4 ### ============================================================================
5 ### Licensed under the Apache License, Version 2.0 (the "License");
6 ### you may not use this file except in compliance with the License.
7 ### You may obtain a copy of the License at
8 ###
9 ###       http://www.apache.org/licenses/LICENSE-2.0
10 ###
11 ### Unless required by applicable law or agreed to in writing, software
12 ### distributed under the License is distributed on an "AS IS" BASIS,
13 ### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ### See the License for the specific language governing permissions and
15 ### limitations under the License.
16 ### ============LICENSE_END=====================================================
17
18 ###
19 ### checkdocs.sh
20 ###
21 ### AUTHOR(S):
22 ### Thomas Kulik, Deutsche Telekom AG, 2020
23 ###
24 ### DESCRIPTION:
25 ### Retrieves a full list of ONAP repos from gerrit inluding their state.
26 ### Clones all active repos of the ONAP master branch plus other requested ONAP
27 ### branches. Then the script does some docs related analyses depending on the
28 ### clone results. It creates logfiles containing filtered results. In addition
29 ### a table.csv is created which can be used to import it in a spreadsheed.
30 ### Also a zip-file is created which contains all the results.
31 ###
32 ### IMPORTANT:
33 ### - in the output, repo names are shown in square brackets for readability
34 ###   e.g [aai/aai-common]/docs/release-notes.rst
35 ### - in the table.csv file you see data for the requested branch if available.
36 ###   if not available, data is retrieved from the master branch. it will be
37 ###   denoted in round brackets, e.g. (3) (tox.ini)
38 ###
39 ### REQUIREMENTS:
40 ### curl
41 ### jq
42 ###
43
44 ###
45 ### SOME HELPING COMMANDS TO PROCESS LOG FILES:
46 ### create repo list
47 ### curl -s https://git.onap.org/ | grep "^<tr><td class='toplevel-repo'><a title='" | sed -r "s:^<tr><td class='toplevel-repo'><a title='::" | sed -r "s:'.*::"
48 ###
49 ### remove branchname from the line
50 ### cat frankfurt_gerritclone.log | sed 's:frankfurt|::'
51 ###
52 ### list only image names
53 ### cat master_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d'
54 ###
55 ### more interesting stuff ...
56 ### curl https://gerrit.onap.org/r/projects/?d
57 ### LONG:  curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g' | sed -r 's:["{}]::g' | sed -r 's:id\:::' | sed -r 's:,state\::|:' | sed '/All-Projects/d' | sed '/All-Users/d'
58 ### SHORT: curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g; s:["{}]::g; s:id\:::; s:,state\::|:; /All-Projects/d; /All-Users/d'
59 ###
60
61 script_version="1.0 (2020-11-16)"
62
63 # save command for the restart with logging enabled
64 command=$0
65 arguments=$@
66 fullcommand="${command} ${arguments}"
67
68 ###
69 ### functions
70 ###
71
72 # print usage
73 function usage() {
74   echo "                                                           "
75   echo " USAGE:                                                    "
76   echo "  ./checkdocs.sh                                           "
77   echo "                                                           "
78   echo " ARGUMENTS:                                                "
79   echo "  -u|--user username                                       "
80   echo "  linux foundation username used to clone ONAP Gerrit repos"
81   echo "                                                           "
82   echo "  -b|--branches branch1,branch2,branch3                    "
83   echo "  list of branches to be cloned. master is automatically   "
84   echo "  added to the list. do not add manually!                  "
85   echo "                                                           "
86   echo "  -d|--dev                                                 "
87   echo "  development-mode - limits number of repos to be cloned   "
88   echo "                                                           "
89 }
90
91 # draw a simple line
92 function drawline {
93   echo "*******************************************************************************"
94 }
95
96 # remove lockfile in case script is interrupted
97 trap InterruptedScript SIGINT SIGTERM SIGHUP SIGKILL SIGSTOP
98 function InterruptedScript {
99   echo " "
100   echo "Script was interrupted."
101   if [ -f $lockfile ] ; then
102     rm $lockfile
103   fi
104   exit 0
105 }
106
107 ###
108 ### arguments handling
109 ###
110
111 PARAMS=""
112
113 while (( "$#" )); do
114   case "$1" in
115     -d|--dev)
116       devmode="TRUE"
117       shift
118       ;;
119     -b|--branches)
120       if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
121         branches_csv=$2
122         shift 2
123       else
124         echo "Error: Argument for $1 is missing" >&2
125         usage
126         exit 1
127       fi
128       ;;
129     -u|--user)
130       if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
131         lfusername=$2
132         shift 2
133       else
134         echo "Error: Argument for $1 is missing" >&2
135         usage
136         exit 1
137       fi
138         ;;
139     -*|--*=) # unsupported flags
140       echo "Error: Unsupported argument $1" >&2
141       usage
142       exit 1
143       ;;
144     *) # preserve positional arguments
145       PARAMS="$PARAMS $1"
146       shift
147       ;;
148   esac
149 done
150
151 # set positional arguments in their proper place
152 eval set -- "$PARAMS"
153
154 # old: declare -a branches=("master" "frankfurt" "guilin")
155 if [[ $branches_csv == "" || $lfusername == "" ]]; then
156   usage
157   exit -1
158 fi
159
160 # master branch is automatically added and must not part of the user arguments
161 if [[ $branches_csv == *"master"* ]]; then
162   usage
163   exit -1
164 fi
165 # clone master first, the the other branches
166 branches_csv="master,${branches_csv}"
167
168 # create the branches array by readinging in the values from the variable
169 IFS=',' read -r -a branches <<< "${branches_csv}"
170
171 #echo "DBUG: devmode      = \"${devmode}\""
172 #echo "DBUG: branches_csv = \"${branches_csv}\""
173 #echo "DBUG: lfusername   = \"${lfusername}\""
174 #echo "DBUG: branches     = \"${branches[@]}\""
175
176 # restart script with logging enabled
177 lockfile="checkdocs-runtime-lockfile"
178 if [ ! -f $lockfile ] ; then
179   touch $lockfile
180   echo "Restarting script with logging enabled."
181   ${fullcommand} 2>&1 | tee checkdocs.log
182   rm $lockfile
183   exit
184 fi
185
186 echo " "
187 echo "checkdocs.sh Version ${script_version}"
188 echo " "
189
190 # curl must be installed
191 if ! command -v curl &> /dev/null
192 then
193   echo "ERROR: curl command could not be found"
194   exit -1
195 fi
196
197 today=$(date '+%Y-%m-%d');
198 repolist="gerrit-repos-master-"$today".txt";
199
200 echo "Retrieving a full list of ONAP repositories (master) from gerrit.onap.org."
201
202 # retrieve the full repolist from gerrit
203 # workaround because of the (wrong?) response of gerrit.onap.org which makes jq command fail
204 # "| awk '{if(NR>1)print}'" filters the first line of the response so that jq will work again (thx marek)
205 curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g; s:["{}]::g; s:id\:::; s:,state\::|:; /All-Projects/d; /All-Users/d' >./$repolist
206
207 # process the created repolist
208 # only active projects will be cloned in case the requested branch of the project exists
209 echo "Accessing gerrit.onap.org with username \"${lfusername}\"."
210 echo "Start cloning of repositories."
211
212 for branch in "${branches[@]}"
213 do
214
215   echo " "
216   echo "###"
217   echo "### ${branch}"
218   echo "###"
219   echo " "
220
221   branch_upper=$(echo "${branch}" | tr '[:lower:]' '[:upper:]')
222
223   mkdir $branch
224   cp $repolist $branch
225   cd $branch
226
227   devcounter=0
228
229   # process repolist
230   while read line
231   do
232
233   if [[ $devmode == "TRUE" ]]; then
234     devcounter=$((devcounter+1))
235   fi
236
237   if [[ $devcounter -lt "11" ]]; then
238
239       if [[ $devmode == "TRUE" ]]; then
240         echo "INFO: devmode! counter=${devcounter}"
241       fi
242
243       drawline
244       reponame=$(echo $line | awk -F "|" '{print $1}');
245       repostate=$(echo $line | awk -F "|" '{print $2}');
246       echo $reponame
247       echo $repostate
248
249       if [[ $repostate == "ACTIVE" ]]; then
250         echo "Cloning \"${branch}\" branch of ACTIVE project ${reponame}..."
251
252         git clone --branch ${branch} --recurse-submodules ssh://${lfusername}@gerrit.onap.org:29418/$reponame ./$reponame
253         gitexitcode=$?
254
255         if [[ ! ${gitexitcode} == "0" ]]; then
256           errormsg=$(tail -1 ../checkdocs.log)
257         else
258           errormsg="cloned"
259         fi
260
261         # gerritclone.log format:  $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
262         echo "${gitexitcode}|${reponame}|${repostate}|${errormsg}" | tee -a ${branch}_gerritclone.log
263
264       elif [[ $repostate == "READ_ONLY" ]]; then
265         echo "-|${reponame}|${repostate}|ignored" | tee -a ${branch}_gerritclone.log
266       else
267         echo "-|${reponame}|unknown repo state \"${repostate}\"|-" | tee -a ${branch}_gerritclone.log
268       fi
269
270       # examine repo
271       if [[ ${gitexitcode} == "0" ]]; then
272
273         printf "\ndocs directories:\n"
274         find ./$reponame -type d -name docs | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_docs.log
275
276         printf "\nrst files:\n"
277         find ./$reponame -type f -name *.rst | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_rstfiles.log
278
279         printf "\nrelease notes rst:\n"
280         find ./$reponame -type f | grep 'release.*note.*.rst' | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_releasenotes.log
281
282         printf "\ntox.ini files:\n"
283         find ./$reponame -type f -name tox.ini | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_toxini.log
284
285         printf "\nconf.py files:\n"
286         find ./$reponame -type f -name conf.py | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_confpy.log
287
288         printf "\nindex.rst files:\n"
289         find ./$reponame -type f -name index.rst | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_indexrst.log
290
291       fi
292
293     # end defcounter loop
294     fi
295
296     gitexitcode=""
297
298   done <${repolist}
299
300   # examine repos
301   drawline
302   find . -type f -name values.yaml -print -exec grep "image:" {} \; | sed -r 's:^ +::' | tee ${branch}_dockerimagesfull.log
303   drawline
304   ls --format single-column -d */ | sed 's:/$::' | tee ${branch}_directories.log
305   drawline
306   cat ${branch}_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d' >${branch}_dockerimages.log
307   drawline
308   ls --format single-column -d oom/kubernetes/*/ | tee ${branch}_oomkubernetes.log
309   drawline
310
311   # examine docs
312   readarray -t docs_array < ./${branch}_docs.log;
313
314   for line in "${docs_array[@]}"
315   do
316
317     echo $line | tee -a ${branch}_docsconfig.log
318
319     # remove [ and ] which are distinguish the project name in the output
320     line=$(echo $line | sed -r 's:\[:: ; s:\]::')
321
322     if [ -f ./${line}/conf.py ] ; then
323       echo "  conf.py ..... found" | tee -a ${branch}_docsconfig.log
324     else
325       echo "  conf.py ..... NOT FOUND" | tee -a ${branch}_docsconfig.log
326     fi
327
328     if [ -f ./${line}/index.rst ] ; then
329       echo "  index.rst ... found" | tee -a ${branch}_docsconfig.log
330     else
331       echo "  index.rst ... NOT FOUND" | tee -a ${branch}_docsconfig.log
332     fi
333
334     if [ -f ./${line}/tox.ini ] ; then
335       echo "  tox.ini ..... found" | tee -a ${branch}_docsconfig.log
336     else
337       echo "  tox.ini ..... NOT FOUND" | tee -a ${branch}_docsconfig.log
338     fi
339
340     echo " " | tee -a ${branch}_docsconfig.log
341
342   done
343   unset docs_array
344
345   drawline
346
347   ###
348   ### build a csv table that combines results
349   ###
350
351   #
352   # csv column #1: project name
353   #
354
355   readarray -t array < ./${repolist};
356   i=0
357   csv[i]="project"
358   ((i++))
359   for line in "${array[@]}"
360   do
361     reponame=$(echo $line | awk -F "|" '{print $1}');
362     project=$(echo $reponame | sed 's:/.*$::')
363     #echo "DBUG: reponame=${reponame}"
364     #echo "DBUG:  project=${project}"
365     #echo "DBUG:        i=${i}"
366     csv[i]=${project}
367     ((i++))
368   done
369   unset array
370   unset i
371   unset reponame
372   unset project
373
374   #
375   # csv column #2: repo name
376   #
377
378   readarray -t array < ./${repolist};
379   i=0
380   csv[i]="${csv[i]},MASTER repo name"
381   ((i++))
382   for line in "${array[@]}"
383   do
384     reponame=$(echo $line | awk -F "|" '{print $1}');
385     csv[i]="${csv[i]},${reponame}"
386     ((i++))
387   done
388   unset array
389   unset i
390   unset reponame
391
392   #
393   # csv column #3: repo state
394   #
395
396   readarray -t array < ./${repolist};
397   i=0
398   csv[i]="${csv[i]},MASTER repo state"
399   ((i++))
400   for line in "${array[@]}"
401   do
402     repostate=$(echo $line | awk -F "|" '{print $2}');
403     csv[i]="${csv[i]},${repostate}"
404     ((i++))
405   done
406   unset array
407   unset i
408   unset repostate
409
410   #
411   # csv column #4: clone message
412   #
413
414   readarray -t array < ./${branch}_gerritclone.log;
415   i=0
416   csv[i]="${csv[i]},${branch_upper} clone message"
417   ((i++))
418   for line in "${array[@]}"
419   do
420     # gerritclone.log format:  $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
421     errormsg=$(echo $line | awk -F "|" '{print $4}');
422     csv[i]="${csv[i]},${errormsg}"
423     ((i++))
424   done
425   unset array
426   unset i
427   unset errormsg
428
429   #
430   # csv column #5: RELEASE component (yes|no|maybe)
431   # to be filled with values of the planned release config file maintained by
432   # the onap release manager
433   #
434
435   # gerritclone.log format:  $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
436   readarray -t array < ./${branch}_gerritclone.log;
437   i=0
438   csv[i]="${csv[i]},${branch_upper} component"
439   ((i++))
440   for line in "${array[@]}"
441   do
442
443     # gerritclone.log format:  $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
444     gitexitcode=$(echo $line | awk -F "|" '{print $1}');
445        reponame=$(echo $line | awk -F "|" '{print $2}');
446       repostate=$(echo $line | awk -F "|" '{print $3}');
447        errormsg=$(echo $line | awk -F "|" '{print $4}');
448
449     if [[ ${repostate} == "ACTIVE" && ${gitexitcode} == "0" ]]; then
450       releasecomponent="yes"
451     elif [[ ${repostate} == "ACTIVE" && ${gitexitcode} == "128" ]]; then
452       releasecomponent="maybe"
453     elif [ ${repostate} == "READ_ONLY" ]; then
454       releasecomponent="no"
455     else
456       releasecomponent="unknown"
457     fi
458
459     csv[i]="${csv[i]},${releasecomponent}"
460     ((i++))
461   done
462   unset array
463   unset i
464   unset gitexitcode
465   unset reponame
466   unset repostate
467   unset errormsg
468   unset releasecomponent
469
470   #
471   # csv column #6: docs (at repo root directory only; no recursive search!)
472   # csv column #7: conf.py
473   # csv column #8: tox.ini
474   # csv column #9: index.rst
475   #
476   # columns are filled with values from requested branch.
477   # if data is not available values from master branch are used.
478   # to identify master branch values, data is put into brackets "(...)"
479   #
480
481   readarray -t array < ./${repolist};
482   i=0
483   csv[$i]="${csv[i]},docs,conf.py,tox.ini,index.rst"
484   ((i++))
485   for line in "${array[@]}"
486   do
487     line=$(echo $line | sed 's:|.*$::')
488     #echo "DBUG: line=${line}"
489     #echo "DBUG: i=${i}"
490
491     # docs
492     if [ -d ./${line}/docs ] ; then
493       docs="docs"
494     elif [ -d ../master/${line}/docs ] ; then
495       docs="(docs)"
496     else
497       docs="-"
498     fi
499
500     # conf.py
501     if [ -f ./${line}/docs/conf.py ] ; then
502       docs="${docs},conf.py"
503     elif [ -f ../master/${line}/docs/conf.py ] ; then
504       docs="${docs},(conf.py)"
505     else
506       docs="${docs},-"
507     fi
508
509     # tox.ini
510     if [ -f ./${line}/docs/tox.ini ] ; then
511       docs="${docs},tox.ini"
512     elif [ -f ../master/${line}/docs/tox.ini ] ; then
513       docs="${docs},(tox.ini)"
514     else
515       docs="${docs},-"
516     fi
517
518     # index.rst
519     if [ -f ./${line}/docs/index.rst ] ; then
520       docs="${docs},index.rst"
521     elif [ -f ../master/${line}/docs/index.rst ] ; then
522       docs="${docs},(index.rst)"
523     else
524       docs="${docs},-"
525     fi
526
527     #echo "DBUG: docs=${docs}"
528     line="${csv[i]},${docs}"
529     csv[$i]=${line}
530     ((i++))
531   done
532   unset array
533   unset i
534   unset docs
535
536   #
537   # csv column #10: index.html@RTD accessibility check
538   # csv column #11: index.html url
539   #
540
541   readarray -t array < ./${branch}_gerritclone.log;
542   i=0
543   csv[i]="${csv[i]},index.html@RTD,index.html url"
544   ((i++))
545   for line in "${array[@]}"
546   do
547     # gerritclone.log format:  $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
548     gitexitcode=$(echo $line | awk -F "|" '{print $1}');
549        reponame=$(echo $line | awk -F "|" '{print $2}');
550       repostate=$(echo $line | awk -F "|" '{print $3}');
551        errormsg=$(echo $line | awk -F "|" '{print $4}');
552
553             url=""
554     curl_result=""
555
556     # this routine works only with release "frankfurt" and later because
557     # earlier releases are using submodule structure for documentation files
558     if echo "$branch" | grep -q '^[abcde]'; then
559       curl_result="unsupported release"
560       url="-"
561     else
562
563       # we are working on "frankfurt" branch or later ...
564       # only if repostate IS ACTIVE a curl test is required
565       if [[ ${repostate} == "ACTIVE" ]]; then
566
567         # OPTIONAL: USE ALSO GITEXITCODE AS A FILTER CRITERIA ???
568
569         # url base
570         url_start="https://docs.onap.org/projects/onap"
571         url_lang="en"
572         url_branch=${branch}
573
574         # "master" branch documentation is available as "latest" in RTD
575         if [[ ${url_branch} == "master" ]]; then
576           url_branch="latest"
577         fi
578
579         # replace all / characters in repo name with - charachter
580         url_repo=$(echo ${reponame} | sed -r 's/\//-/g')
581         url_file="index.html"
582
583         # build the full url
584         url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}"
585         #echo "DBUG: url=$url"
586
587         # test accessibility of url
588         curl --head --silent --fail "${url}" >/dev/null
589         curl_result=$?
590
591         # convert numeric results to text
592         if [ "${curl_result}" = "0" ]; then
593           curl_result="accessible"
594         elif [ "${curl_result}" = "22" ]; then
595           curl_result="does not exist"
596         else
597           curl_result="ERROR:${curl_result}"
598         fi
599
600         # url does not exist for this branch.
601         # in case the requested url is not already for "master" branch,
602         # we try to access the url of the master branch and denote the
603         # result by using round brackets (result)
604         if [[ ${curl_result} == "does not exist" && ! $branch == "master" ]]; then
605
606           # build the full (master/latest) url
607           url="${url_start}-${url_repo}/${url_lang}/latest/${url_file}"
608           #echo "DBUG: url=$url"
609
610           # test accessibility of url in "master branch" (latest)
611           curl --head --silent --fail "${url}" >/dev/null
612           curl_result=$?
613           # denote result as a value from "master" branch (latest)
614           url="(${url})"
615
616           # convert numeric results to text
617           if [ "${curl_result}" = "0" ]; then
618             curl_result="(accessible)"
619           elif [ "${curl_result}" = "22" ]; then
620             curl_result="(does not exist)"
621           else
622             curl_result="(ERROR:${curl_result})"
623           fi
624
625         fi
626       else
627         # repostate IS NOT ACTIVE - no curl test required
628         curl_result="-"
629         url="-"
630       fi
631     fi
632
633     echo "$url ... $curl_result"
634     csv[i]="${csv[i]},${curl_result},${url}"
635     #echo "DBUG: csv line=${csv[i]}"
636
637     ((i++))
638   done
639
640   #
641   # csv column #12: release notes
642   #
643
644   readarray -t array < ../${repolist};
645   i=0
646   csv[i]="${csv[i]},release notes"
647   ((i++))
648   for line in "${array[@]}"
649   do
650     line=$(echo $line | sed 's:|.*$::')
651     #echo "DBUG: line=\"${line}\""
652     #echo "DBUG: i=${i}"
653     relnote=""
654
655     # put repo name in square brackets for increased grep hit rate
656     # escape minus and bracket characters to avoid problems with the grep command
657     #repo_grepable=$(echo ${line} | sed -r s:${line}:[${line}]: | sed -r 's/-/\\-/g' | sed -r 's/\[/\\[/g' | sed -r 's/\]/\\]/g')
658     #echo "DBUG: repo_grepable=\"${repo_grepable}\""
659
660     # check if repo dir exists in this branch
661     if [ -d ./${line} ] ; then
662       # if yes, check if repo name appears in the branch releasenotes.log
663       relnote=$(find "./${line}" -type f | grep 'release.*note.*.rst' | wc -l);
664       # repo dir DOES NOT exist in this branch - so check if repo dir exists in MASTER branch
665     elif [ -d ../master/${line} ] ; then
666       # if yes, check if repo name appears in the MASTER releasenotes.log
667       # count release notes files in MASTER branch (in repo root and its subdirectories)
668       relnote=$(find "../master/${line}" -type f | grep 'release.*note.*.rst' | wc -l);
669       # put results in round brackets to show that this is MASTER data
670       relnote=$(echo ${relnote} | sed -r s:${relnote}:\(${relnote}\):)
671     else
672       relnote="-"
673     fi
674
675     line="${csv[i]},${relnote}"
676     csv[i]=${line}
677     ((i++))
678
679   done
680   unset array
681   unset i
682   unset relnote
683   unset repo_grepable
684
685   #
686   # build the table.csv file
687   #
688
689   for i in "${csv[@]}"
690   do
691     echo "$i" | tee -a ./${branch}_table.csv
692   done
693
694   #
695   # create data package for this branch and zip it
696   #
697
698   datadir=${branch}_data
699   mkdir $datadir
700   cp $repolist $datadir
701   cp ${branch}_table.csv $datadir
702   cp ${branch}_*.log $datadir
703   zip -r ${datadir}.zip $datadir
704
705   # return from the branch directory
706   cd ..
707
708 # return and work on the next requested branch ... or exit
709 done