+# function to parse wiki (project) lifecycle state information
+# call: getwikilifecyclestate "projectname"
+# result: $return_from_getwikilifecyclestate
+# because bash supports only returning numeric values a variable $return_from_getwikilifecyclestate is used
+
+function getwikilifecyclestate {
+
+ local requested=$1
+ local wikiline=""
+ local wikirepo=""
+ local wikistate=""
+
+ return_from_getwikilifecyclestate=""
+
+ for wikiline in "${wikiplsarray[@]}"
+ do
+
+ wikirepo=$(echo $wikiline | awk -F ";" '{print $1}');
+ wikistate=$(echo $wikiline | awk -F ";" '{print $2}');
+
+ #echo "DBUG: getwikilifecyclestate wikiline = \"${wikiline}\"";
+ #echo "DBUG: getwikilifecyclestate wikirepo = \"${wikirepo}\""
+ #echo "DBUG: getwikilifecyclestate wikistate = \"${wikistate}\""
+
+ if [[ ${wikirepo} == ${requested} ]]; then
+ return_from_getwikilifecyclestate=${wikistate}
+ #echo "DBUG: getwikilifecyclestate wikirepo = \"${wikirepo}\""
+ #echo "DBUG: getwikilifecyclestate requested = \"${requested}\""
+ #echo "DBUG: return_from_getwikilifecyclestate = \"${return_from_getwikilifecyclestate}\"";
+ return 0;
+ fi
+
+ done
+
+ #echo "DBUG: getwikilifecyclestate requested \"${requested}\" NOT FOUND in list"
+ return_from_getwikilifecyclestate=""
+
+}
+
+# function to parse release partizipation information
+# call: getrpinfo "projectname"
+# result: $return_from_getrpinfo
+# because bash supports only returning numeric values a variable $return_from_getrpinfo is used
+
+function getrpinfo {
+
+ local requested=$1
+
+ # clean up first
+ local rpdetails=""
+ local rpline=""
+ local rprepo=""
+ local rpproject=""
+ local current_branch_starting_letter=""
+ return_from_getrpinfo=""
+
+ # finds first matching line in the array using grep (currently every line shows the same partizipation for the project (NOT repository!) )
+ # this is much faster then looping line by line
+ rpline=$(IFS=$'\n'; echo "${rparray[*]}" | grep -m 1 ";${requested};");
+ rpline=$(echo ${rpline} | tr -d '^M')
+ rprepo=$(echo ${rpline} | awk -F ";" '{print $1}');
+ rpproject=$(echo ${rpline} | awk -F ";" '{print $2}');
+ # concatenate details to do an easy grep later on to find out if or if not the project/repo has partizipated to a release
+ rpdetails=$(echo ${rpline} | awk -F ";" '{print "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9 "-" $10 "-" $11 "-" $12 "-"}');
+
+ # result will be e.g. "-g" and this avoids false positives with the "m" release
+ # (because "m" is also used to indicate the maintenance release, e.g. "gm")
+ current_branch_starting_letter="-${branch:0:1}"
+
+ #echo "DBUG: getrpinfo ****************************";
+ #echo "DBUG: getrpinfo requested = \"${requested}\"";
+ #echo "DBUG: getrpinfo rpproject = \"${rpproject}\"";
+ #echo "DBUG: getrpinfo rpdetails = \"${rpdetails}\"";
+ #echo "DBUG: current branch = \"${branch}\"";
+ #echo "DBUG: starting_letter = \"${current_branch_starting_letter}\"";
+
+ ## check if PROJECT has partizipated to INITIAL release
+ #if [[ ${rpproject} = ${requested} ]] && [[ "${rpdetails}" == *"${current_branch_starting_letter}-"* ]]; then
+ # return_from_getrpinfo="project | ${current_branch_starting_letter:1:1}"
+ # # check ADDITIONALLY if PROJECT has ALSO partizipated to MAINTENANCE release
+ # if [[ "${rpdetails}" == *"${current_branch_starting_letter}m-"* ]]; then
+ # return_from_getrpinfo="${return_from_getrpinfo} | ${current_branch_starting_letter:1:1}m"
+ # #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\"";
+ # fi
+ # return 0;
+ ## check if PROJECT has ONLY partizipated to MAINTENANCE release
+ #elif [[ ${rpproject} = ${requested} ]] && [[ "${rpdetails}" == *"${current_branch_starting_letter:1:1}m-"* ]]; then
+ # return_from_getrpinfo="project | ${current_branch_starting_letter:1:1}m"
+ # #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\"";
+ # return 0;
+ #fi
+
+ # check if requested PROJECT was found in the array of partizipating projects
+ if [[ ${rpproject} = ${requested} ]]; then
+ # check if PROJECT has partizipated to INITIAL release
+ if [[ "${rpdetails}" == *"${current_branch_starting_letter}-"* ]]; then
+ return_from_getrpinfo="project | ${current_branch_starting_letter:1:1}"
+ # check ADDITIONALLY if PROJECT has ALSO partizipated to MAINTENANCE release
+ if [[ "${rpdetails}" == *"${current_branch_starting_letter}m-"* ]]; then
+ return_from_getrpinfo="${return_from_getrpinfo} ${current_branch_starting_letter:1:1}m"
+ #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\"";
+ fi
+ return 0;
+ elif [[ "${rpdetails}" == *"${current_branch_starting_letter:1:1}m-"* ]]; then
+ return_from_getrpinfo="project | ${current_branch_starting_letter:1:1}m"
+ #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\"";
+ return 0;
+ fi
+ fi
+ #echo "DBUG: getrpinfo requested \"${requested}\" NOT FOUND in list"
+ return_from_getrpinfo=""
+}
+
+function find_repo_in_confpy {
+
+ local search_term=$1
+ local search_term_line_number=""
+ local confpy_branch_entries=""
+ local confpy_line_number=""
+ local confpy_branch_name=""
+ local idx=""
+
+ return_from_find_repo_in_confpy=""
+ search_term="'${search_term}'"
+
+ search_term_line_number=$(cat ./doc/docs/conf.py | grep -n '^intersphinx_mapping\[' | grep -m 1 ${search_term} | sed 's/:.*//')
+ #echo "DBUG: search_term is ............... ${search_term}"
+ #echo "DBUG: search_term_line_number is ... ${search_term_line_number}"
+
+ # nothing (or multiple entries) found - return
+ if [[ ${search_term_line_number} == "" ]]; then
+ #echo "DBUG: search_term_line_number is empty - returning"
+ return_from_find_repo_in_confpy=""
+ return 0;
+ fi
+
+ readarray -t confpy_branch_entries <<< "$(cat ./doc/docs/conf.py | grep -n '^branch = ' | sed 's/branch = //' | sed s/\'//g)"
+
+ #echo "DBUG: confpy_branch_entries"
+ #printf -- "%s\n" "${confpy_branch_entries[@]}"
+ #for confpy_branch_entry in ${confpy_branch_entries[@]}
+ #do
+ # confpy_line_number=$(echo $confpy_branch_entry | awk -F ":" '{print $1}');
+ # confpy_branch_name=$(echo $confpy_branch_entry | awk -F ":" '{print $2}');
+ # echo "DBUG: ${confpy_branch_name} entries are below line ${confpy_line_number}"
+ #done
+
+ # search in the list of branches in reverse order
+ for (( idx=${#confpy_branch_entries[@]}-1 ; idx>=0 ; idx-- ))
+ do
+ #echo "DBUG: working entry is ${confpy_branch_entries[idx]}"
+ confpy_line_number=$(echo ${confpy_branch_entries[idx]} | awk -F ":" '{print $1}');
+ confpy_branch_name=$(echo ${confpy_branch_entries[idx]} | awk -F ":" '{print $2}');
+ #echo "DBUG: ${confpy_branch_name} entries are below line ${confpy_line_number}"
+
+ if (( ${search_term_line_number} > ${confpy_line_number} )); then
+ #echo "DBUG: search_term_line_number is greater than confpy_line_number"
+ #echo "DBUG: ${search_term} found in ${confpy_branch_name} section"
+ return_from_find_repo_in_confpy=${confpy_branch_name}
+ return 0;
+ fi
+ done
+}
+