-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61a0759
commit 40519b1
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# A helper to merge e.g. a PR from draft to an RC branch where any neccessary | ||
# conflicts resolutions are expected to have been trained with rerere. | ||
# | ||
# It merges PRs from "origin" remote which should be set to "[email protected]:anoma/namada.git". | ||
# Make sure to fetch latest before running with e.g. `git fetch origin`. | ||
# | ||
# Requires `gh` to be installed and authenticated. | ||
# | ||
# Usage example: | ||
# $ scripts/merge_pr.sh 2627 2db3acdb21581bb502b27dc9c1c831b4e94ad013 && \ | ||
# $ scripts/merge_pr.sh 2698 0d3b252e7f5ceb85a276966fe8ee7d7e1c0c6e63 ce68d3a57eb342495a43dc65ee03394b116fd484 && \ | ||
# $ scripts/merge_pr.sh 2819 | ||
# | ||
# The first argument is a PR number, followed by any number of evil commit | ||
# hashes. | ||
|
||
set -Eo pipefail | ||
|
||
PR_NUM=$1 | ||
|
||
BRANCH=$(gh pr view "$PR_NUM" --json headRefName -q .headRefName) | ||
echo "🔴 Merging branch $BRANCH https://github.com/anoma/namada/pull/$PR_NUM ..." | ||
|
||
# TODO: handle cross-repository PRs (and remote & fetch) | ||
IS_CROSS=$(gh pr view "$PR_NUM" --json isCrossRepository -q .isCrossRepository) | ||
if [ "$IS_CROSS" == "true" ]; then | ||
echo "🪦 Cross-repository PR, manual intervention needed for PR #$PR_NUM" | ||
exit 1 | ||
fi | ||
|
||
# Merge the PR | ||
git merge --no-ff -m "Merge branch '$BRANCH' (#$PR_NUM)" origin/"$BRANCH" | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "" | ||
echo "In rerere we trust 🙏" | ||
|
||
git add wasm_for_tests/*.wasm | ||
|
||
git commit --no-edit | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "🪦 Automatic resolution failed, manual intervention needed for PR #$PR_NUM" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Add evil commits | ||
for var in "${@:2}" # Skip the first arg (PR number) | ||
do | ||
echo "" | ||
echo "🙉 Adding evil $var..." | ||
git cherry-pick --no-commit "$var" | ||
git commit --amend --no-edit | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "🪦 Evil commit failed to apply, manual intervention needed for PR #$PR_NUM" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "" | ||
echo "" |