Skip to content

Commit

Permalink
Allow release-all to handle an accidental manual merge (#239)
Browse files Browse the repository at this point in the history
If a release branch PR has been accidently merged manually rather than
using the "-P merge-pr" option, then a subsequent "-P tag-release" will
fail to find the expected text in the merge PR.

This adds a "-x" option that can be used to help release-all in that case,
to give it the release name that it was expecting to find in the merge PR.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Dec 12, 2024
1 parent 30bf707 commit 7d50ddc
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions tools/release-all/release-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ PHASE="master"
usage() {
echo "Usage: $PROG [-h]"
echo " $PROG [-L]"
echo " $PROG [-w workspace_dir] [-P phase] [-R repo-names] [-B part]"
echo " $PROG [-w workspace_dir] [-P phase] [-R repo-names] [-B part] [-x THINGS]"
echo
echo " -B part Indicates which part of the version to bump for"
echo " the new release. Default: '$SEMVER_BUMP'."
Expand All @@ -108,11 +108,16 @@ usage() {
echo " -R repo_names Comma-separated list of repo names to operate on."
echo " If unspecified, then all repos will be used."
echo " -w workspace_dir Name for working directory. Default: '$WORKSPACE'"
echo " -x THINGS A list of colon-separated manual overrides."
echo " 'force-tag=vX.Y.Z' Use tag vX.Y.Z during the tag-release"
echo " phase. Use this if you accidently did"
echo " a manual merge rather than using the"
echo " merge-pr phase above."
echo
echo "See README.md for detailed instructions"
}

while getopts "B:LP:R:w:h" opt; do
while getopts "B:LP:R:w:x:h" opt; do
case $opt in
B)
case $OPTARG in
Expand Down Expand Up @@ -149,6 +154,22 @@ while getopts "B:LP:R:w:h" opt; do
w)
WORKSPACE="$OPTARG"
;;
x)
OVERRIDES=${OPTARG//:/ }
bad_one=
for override in $OVERRIDES; do
if [[ "$override" =~ ^force\-tag=v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
FORCE_TAG_VALUE=${override//force-tag=/}
echo "Using force-tag: $FORCE_TAG_VALUE"
else
echo "Unrecognized -x option: $override"
bad_one=yes
fi
done
if [[ -n $bad_one ]]; then
exit 1
fi
;;
h)
usage
exit 0
Expand Down Expand Up @@ -825,7 +846,20 @@ tag_release_vX() {

latest_release=$(git describe --match="v*" --abbrev=0 HEAD) || do_fail "${indent}Failure getting latest release tag."

merge_release=$(git log --oneline -1 | sed 's/^.* Merge release \(.*\)/\1/')
most_recent_commit=$(git log --oneline -1)
if [[ "$most_recent_commit" =~ " Merge release " ]]; then
merge_release=$(git log --oneline -1 | sed 's/^.* Merge release \(.*\)/\1/')
elif [[ -n $FORCE_TAG_VALUE ]]; then
echo
msg "${indent}WARNING"
msg "${indent}Using -x override to set release version: $FORCE_TAG_VALUE"
msg "${indent}WARNING"
echo
merge_release="$FORCE_TAG_VALUE"
fi
if [[ -z $merge_release ]]; then
do_fail "${indent}Did not find the merge commit, or a -x override."
fi
msg "${indent}Expecting to tag as release $merge_release"

# Is it already tagged?
Expand Down

0 comments on commit 7d50ddc

Please sign in to comment.