Skip to content

Commit

Permalink
Move check_marked_as_integrated from master to main
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Nov 15, 2023
1 parent 23de098 commit f3cf55b
Showing 1 changed file with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
#gitcmd: git cli path
#gitdir: git directory with integration.git repo
#gitremotename: integration.git remote name
#currentmaster: Deprecated, use devbranches instead. The final major version current master will be (e.g. 32).
#devbranches: the next major versions ($branch) under development, comma separated. Ordered by release "distance".
# Since 3.10 (310) always use 3 digits. The last element in the list is assumed to be "master",
# Since 3.10 (310) always use 3 digits. The last element in the list is assumed to be "main",
# The rest are MOODLE_branch_STABLE ones. Normally only one, but when we are in parallel
# development periods, for example: 310,400 (3.10 and 4.0)

Expand All @@ -22,11 +21,6 @@ if [ -z "$gitremotename" ]; then
gitremotename="origin"
fi

# TODO: Remove these backward compatibility lines after some prudential time (say, in 2021).
if [ -z "$devbranches" ] && [ -n "$currentmaster" ]; then
devbranches=$currentmaster
fi

# Verify everything is set
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass gitcmd gitdir gitremotename devbranches"
for var in $required; do
Expand Down Expand Up @@ -77,25 +71,25 @@ ${gitcmd} fetch ${gitremotename}

# While looking at all the issues in integration, capture some variables to use
# for unowned commits check later.
# Pre-fill them with current development branches, note that last element is master, no MOODLE_branch_STABLE.
# Pre-fill them with current development branches, note that last element is main, no MOODLE_branch_STABLE.
for devbranchcode in "${devbranchesarr[@]}"; do
if [[ ${devbranchesarr[${#devbranchesarr[@]}-1]} != ${devbranchcode} ]]; then
activebranches+=(MOODLE_${devbranchcode}_STABLE)
else
activebranches+=(master)
activebranches+=(main)
fi
done
issues=() # The list of issues in current integration.
declare -A branchesbyissue # Associative array, issues as key, branches from fix versions
# in the tracker as value. Format: [MDL-123]=>MOODLE_311_STABLE, master
# in the tracker as value. Format: [MDL-123]=>MOODLE_311_STABLE, main

####
# Iterate over issues in integration and check their commits are integrated in the
# specified branches.
####
issueslist=$( cat "${resultfile}" )
while read -r line; do
ismasteronly=
ismainonly=
issue=$( echo ${line} | sed -n 's/^"\(MDL-[0-9]*\)".*/\1/p' )
issues+=($issue)

Expand All @@ -106,9 +100,9 @@ while read -r line; do

echo "Processing ${issue}"

if [[ $line == *"master-only"* ]]
if [[ $line == *"main-only"* ]]
then
ismasteronly=1
ismainonly=1
fi

fixversions=$( echo ${line} \
Expand All @@ -124,7 +118,7 @@ while read -r line; do

devfound=0
stablefound=0
masterfixversionfound=
mainfixversionfound=
branchesfromfixversion=
while read -r tagversion; do

Expand All @@ -141,10 +135,10 @@ while read -r line; do

if [[ ${devbranchesarr[@]} =~ $majorversion ]]; then
devfound=$((devfound+1))
# Last element corresponds to master, previous ones to MOODLE_branch_STABLE
# Last element corresponds to main, previous ones to MOODLE_branch_STABLE
if [[ ${devbranchesarr[${#devbranchesarr[@]}-1]} == $majorversion ]]; then
branchname=master
masterfixversionfound=${tagversion}
branchname=main
mainfixversionfound=${tagversion}
else
branchname="MOODLE_${majorversion}_STABLE"
fi
Expand All @@ -171,9 +165,9 @@ while read -r line; do

done <<< "${fixversions}"

# And, if master is missing... add it, we'll need it later.
if [[ ! ${branchesfromfixversion} =~ master ]]; then
branchesfromfixversion+=master
# And, if main is missing... add it, we'll need it later.
if [[ ! ${branchesfromfixversion} =~ main ]]; then
branchesfromfixversion+=main
fi
# Add the branches from the tracker fix versions to the branchesbyissue associative array.
branchesbyissue[${issue}]=${branchesfromfixversion}
Expand All @@ -187,37 +181,37 @@ while read -r line; do
# If we haven't checked all dev branches (we don't add dev versions to fixVersion) we
# check it here. May report false positives, but normally everything going to stables
# must go also to ALL dev branches (unless the skip-ci-version-check is used for the issue).
# Only allowed exception is when an issue only has master commits and the "master-only" label.
# Only allowed exception is when an issue only has main commits and the "main-only" label.
if [ $devfound -lt ${#devbranchesarr[@]} ]; then
examiningmaster=
examiningmain=
for devbranchcode in "${devbranchesarr[@]}"; do
if [[ ${devbranchesarr[${#devbranchesarr[@]}-1]} != ${devbranchcode} ]]; then
branch=${gitremotename}/MOODLE_${devbranchcode}_STABLE
examiningmaster=
examiningmain=
else
branch=${gitremotename}/master
examiningmaster=1
branch=${gitremotename}/main
examiningmain=1
fi

# If the commit doesn't exits...
if ! check_issue "${gitcmd}" "${issue}" "${branch}"; then
# Only allowed exception is having the master-only label when examining non-master branches
if [[ -n "$ismasteronly" ]] && [[ -z "$examiningmaster" ]]; then
echo " - has the "master-only" label, not looking for "${branch}" commits."
# Only allowed exception is having the main-only label when examining non-main branches
if [[ -n "$ismainonly" ]] && [[ -z "$examiningmain" ]]; then
echo " - has the "main-only" label, not looking for "${branch}" commits."
else
# If no master-only label and missing commit is not in master, personalize the error about that.
if [[ -z "$ismasteronly" ]] && [[ -z "$examiningmaster" ]]; then
errors+=("${issue} - no commit present in ${branch}. Maybe correct and the issue is 'master-only' ? Add the label if that's the case.")
# If no main-only label and missing commit is not in main, personalize the error about that.
if [[ -z "$ismainonly" ]] && [[ -z "$examiningmain" ]]; then
errors+=("${issue} - no commit present in ${branch}. Maybe correct and the issue is 'main-only' ? Add the label if that's the case.")
else
errors+=("${issue} - no commit present in ${branch}. Add 'skip-ci-version-check' label if this is expected.")
fi
fi

# If the commit exists...
else
# If the issue has the master-only label and we have found commits in non-master dev branches, something is wrong.
if [[ -n "$ismasteronly" ]] && [[ -z "$examiningmaster" ]]; then
errors+=("${issue} - commit found in ${branch}. Check if the 'master-only' label in the issue is correct.")
# If the issue has the main-only label and we have found commits in non-main dev branches, something is wrong.
if [[ -n "$ismainonly" ]] && [[ -z "$examiningmain" ]]; then
errors+=("${issue} - commit found in ${branch}. Check if the 'main-only' label in the issue is correct.")
fi
fi
done
Expand All @@ -234,10 +228,10 @@ while read -r line; do
errors+=("${issue} - cannot set multiple dev fix versions in the Tracker (earliest to be released wins). Please solve that.")
fi

# Under parallel development only, if has master as fix version, then it must have the "master-only" branch.
# Under parallel development only, if has main as fix version, then it must have the "main-only" branch.
if [ ${#devbranchesarr[@]} -gt 1 ]; then
if [[ -n "$masterfixversionfound" ]] && [[ -z "$ismasteronly" ]]; then
errors+=("${issue} - cannot use the master ($masterfixversionfound) fix version without setting the "master-only" label.")
if [[ -n "$mainfixversionfound" ]] && [[ -z "$ismainonly" ]]; then
errors+=("${issue} - cannot use the main ($mainfixversionfound) fix version without setting the "main-only" label.")
fi
fi

Expand Down

0 comments on commit f3cf55b

Please sign in to comment.