Skip to content

Commit

Permalink
DynamatrixStash: checkoutCleanSrc(): try to make master branch known …
Browse files Browse the repository at this point in the history
…even if we are not building it

Should address networkupstools/nut#2551

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
  • Loading branch information
jimklimov committed Jul 25, 2024
1 parent 7b3010a commit 3f8c2e1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/org/nut/dynamatrix/DynamatrixStash.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,33 @@ class DynamatrixStash {
res = scmbody()
}

if (scmCommit != "master" && script.isUnix()) {
// Instantiate local master branch, if absent:
// PRs aimed at another branch only cause their
// source and target branches be known, but not
// master that is used for some ChangeLogs, etc.
script.sh label:"Learn the recent history of master branch", script:"""
git log -1 master && exit
REFREPO='${getGitRefrepoDir(script)}'
if [ x"\${REFREPO}" == xnull ] || [ x"\${REFREPO}" == x ] || [ ! -d "\${REFREPO}" ] ; then
REFREPO=""
fi
for R in \$REFREPO `git remote` ; do
# Start by branching from a locally known replica, if any
git log -1 "\$R/master" && git branch master "\$R/master" && exit
# Continue by requesting an update from git remote(s),
# including registration of a branch newly known in index
git fetch "\$R" "refs/heads/master:remotes/\$R/master" \\
&& git fetch "\$R" "refs/heads/master:refs/heads/master"
done
echo "FAILED to fetch a master branch; some build nuances may misbehave" >&2
"""
}

if (untieRefrepoNow) {
// For initial checkouts headed to stashing
// Not desired for subsequent checkouts on build agents
Expand Down

0 comments on commit 3f8c2e1

Please sign in to comment.