Skip to content

Commit c728116

Browse files
authored
chore: support passing relevant release tags to update-4x-branch.sh as arguments (#4400)
./dev-utils/update-4x-branch.sh [TARGTAG [LASTTAG]] Passing TARGTAG is needed when the HEAD commit is no longer the tagged release commit. Passing LASTTAG is necessary if the 4.x branch wasn't updated for a particular release.
1 parent ff08a11 commit c728116

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

dev-utils/update-4x-branch.sh

+28-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# just-tagged release. The 4.x branch needs to be updated for the current docs
55
# build.
66
#
7+
# Usage:
8+
# ./dev-utils/update-4x-branch.sh [TARGTAG [LASTTAG]]
79

810
if [ "$TRACE" != "" ]; then
911
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
@@ -27,24 +29,37 @@ cd $WRKDIR
2729
git clone [email protected]:elastic/apm-agent-nodejs.git
2830
cd apm-agent-nodejs
2931

30-
TARGTAG=$(git tag --points-at HEAD)
32+
# Allow passing in target tag (first arg), in case the latest commit is no
33+
# longer the tagged release commit.
34+
TARGTAG="$1"
35+
if [[ -z "$TARGTAG" ]]; then
36+
TARGTAG=$(git tag --points-at HEAD)
37+
fi
3138
if [[ ! ("$TARGTAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]$) ]]; then
32-
fatal "the tag on HEAD, '${TARGTAG}', does not look like a release tag"
39+
fatal "the target tag, '${TARGTAG}', does not look like a release tag"
3340
fi
3441
# echo "TARGTAG=$TARGTAG"
3542

36-
readonly NUM_COMMITS_SANITY_GUARD=200
37-
LASTTAG=$(
38-
git log --pretty=format:%h -$NUM_COMMITS_SANITY_GUARD | tail -n +2 | while read sha; do
39-
possible=$(git tag --points-at $sha)
40-
if [[ "$possible" =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]; then
41-
echo $possible
42-
break
43-
fi
44-
done
45-
)
43+
# Allow passing in last tag (second arg), in case the 4.x branch wasn't updated
44+
# for some previous releases.
45+
LASTTAG="$2"
4646
if [[ -z "$LASTTAG" ]]; then
47-
fatal "could not find previous release tag in last $NUM_COMMITS_SANITY_GUARD commits"
47+
readonly NUM_COMMITS_SANITY_GUARD=200
48+
LASTTAG=$(
49+
git log --pretty=format:%h -$NUM_COMMITS_SANITY_GUARD | tail -n +2 | while read sha; do
50+
possible=$(git tag --points-at $sha)
51+
if [[ "$possible" =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]; then
52+
echo $possible
53+
break
54+
fi
55+
done
56+
)
57+
if [[ -z "$LASTTAG" ]]; then
58+
fatal "could not find previous release tag in last $NUM_COMMITS_SANITY_GUARD commits"
59+
fi
60+
fi
61+
if [[ ! ("$LASTTAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]$) ]]; then
62+
fatal "the last tag, '${LASTTAG}', does not look like a release tag"
4863
fi
4964
# echo "LASTTAG=$LASTTAG"
5065

0 commit comments

Comments
 (0)