Skip to content

Commit

Permalink
[Ops] fix emergency release pipeline to work in Buildkite env (#176906)
Browse files Browse the repository at this point in the history
The old code expected the branch to be available locally. If it wasn't
it would fail. With this change, it now runs the commands "against" the
remote repository instead, so it shouldn't matter what's available
locally.
  • Loading branch information
Thomas Watson committed Feb 14, 2024
1 parent b6484a8 commit a3289a3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

set -euo pipefail

echo "--- Verify $BUILDKITE_COMMIT exists in $BUILDKITE_BRANCH"
echo "--- Verify $BUILDKITE_COMMIT exists in origin/$BUILDKITE_BRANCH"
# Step 1: Check if the commit is in the specific named branch
if git merge-base --is-ancestor $BUILDKITE_COMMIT $BUILDKITE_BRANCH; then
if git merge-base --is-ancestor $BUILDKITE_COMMIT origin/$BUILDKITE_BRANCH; then
echo "Commit $BUILDKITE_COMMIT is part of the $BUILDKITE_BRANCH branch"

# Step 2: Check if the commit is also part of any other branches
# This command lists all branches containing the commit and counts them
branches_containing_commit=$(git branch --contains $BUILDKITE_COMMIT | wc -l)
branches_containing_commit=$(git branch -r --contains $BUILDKITE_COMMIT | wc -l)

# If the commit is in more than one branch, exit with non-zero
if [[ $branches_containing_commit -gt 1 ]]; then
Expand Down

0 comments on commit a3289a3

Please sign in to comment.