Skip to content

Commit be40c70

Browse files
committed
bootstrap-tarballs: Document code for fetching PR info
Ticket: ENT-12600 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 8a5551b commit be40c70

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

build-scripts/bootstrap-tarballs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,39 @@ mkdir -p $BASEDIR/output/tarballs
1414
# the first part of the script is not really critical
1515
set +e
1616

17-
# Get information about PRs among the used revisions.
18-
# These PRs will have to be notified of build progress.
17+
# Get information about PRs among the used revisions. These PRs will have to be
18+
# notified of build progress.
19+
#
20+
# Variables such as MISSION_PORTAL_REV may be set by the CI (Jenkins) to build
21+
# and test multiple PR's together. The variables typically hold a branch name
22+
# or a pull request ID. PR IDs are preceded by 'pull' or 'origin/pull'. E.g.:
23+
# - MISSION_PORTAL_REV=pull/1755
24+
# - MISSION_PORTAL_REV=origin/pull/1755
25+
# where the trailing number is the pull request ID.
26+
#
27+
# This loop fetches information about the PRs if the respective variable is set.
28+
#
1929
for repo_spec in cfengine/buildscripts cfengine/core cfengine/masterfiles cfengine/enterprise cfengine/nova cfengine/mission-portal NorthernTechHQ/libntech; do
2030
# remove organization/ from start of repo_spec
31+
# E.g. 'cfengine/mission-portal' -> 'mission-portal'
2132
repo="${repo_spec#*/}"
33+
34+
# Convert to uppercase, swap hyphens with underscore and append '_REV'
35+
# E.g. 'mission-portal' -> 'MISSION_PORTAL_REV'
2236
rev_param_name="$(echo $repo | tr '[:lower:]-' '[:upper:]_')_REV"
37+
38+
# Try to dereference the result from above and skip the rest of the loop
39+
# unless the variable is defined.
2340
revision="$(echo ${!rev_param_name})" || continue # dereference
2441

2542
# remove "origin/" (if any)
2643
revision="${revision##origin/}"
44+
45+
# Check to see if the resolved variable starts with 'pull/'
2746
if expr "$revision" : "pull/" >/dev/null; then
47+
# Extract the revision number. E.g. 'pull/1755' -> '1755'
2848
pr_nr="$(echo $revision | cut -d/ -f2)"
49+
2950
get-github-pull-request-info "$repo_spec" "$pr_nr" >> $BASEDIR/output/PRs
3051
fi
3152
done
@@ -103,4 +124,3 @@ if test -f "$BASEDIR/mission-portal/ldap/composer.json"; then
103124
php /usr/bin/composer.phar install --no-dev
104125
fi
105126
)
106-

0 commit comments

Comments
 (0)