aboutsummaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorGuillaume Melquiond2019-03-26 11:25:13 +0100
committerGuillaume Melquiond2019-03-26 11:25:13 +0100
commit9c821d8dde1d6173a1f2a92f8c98c1c61d81c3c6 (patch)
tree490e141916632a242b65e609dd7a4eb8aca455ef /dev
parenta59d80d3d482813b3c3c1ebce18ae39c3d09e5be (diff)
Improve the backport script.
It now uses the origin/master branch rather than the master branch, thus avoiding the need for local merges. More importantly, it no longer creates a subshell in case of conflicts, but instead gives control back to the user. Once conflicts are solved, it suffices to relaunch the script (instead of exiting the subshell). The reason is that, otherwise, there was no sane way of giving up a backport, due to the infinite subshell loop.
Diffstat (limited to 'dev')
-rwxr-xr-xdev/tools/backport-pr.sh30
1 files changed, 18 insertions, 12 deletions
diff --git a/dev/tools/backport-pr.sh b/dev/tools/backport-pr.sh
index 9864fd4d69..1ec8251f66 100755
--- a/dev/tools/backport-pr.sh
+++ b/dev/tools/backport-pr.sh
@@ -30,13 +30,15 @@ while [[ $# -gt 0 ]]; do
esac
done
-if ! git log master --grep "Merge PR #${PRNUM}" | grep "." > /dev/null; then
+MASTER=origin/master
+
+if ! git log $MASTER --grep "Merge PR #$PRNUM" | grep "." > /dev/null; then
echo "PR #${PRNUM} does not exist."
exit 1
fi
-SIGNATURE_STATUS=$(git log master --grep "Merge PR #${PRNUM}" --format="%G?")
-git log master --grep "Merge PR #${PRNUM}" --format="%GG"
+SIGNATURE_STATUS=$(git log $MASTER --grep "Merge PR #$PRNUM" --format="%G?")
+git log $MASTER --grep "Merge PR #$PRNUM" --format="%GG"
if [[ "$NO_SIGNATURE_CHECK" != "true" && "$SIGNATURE_STATUS" != "G" ]]; then
echo
read -p "Merge commit does not have a good (valid) signature. Bypass? [y/N] " -n 1 -r
@@ -47,10 +49,18 @@ if [[ "$NO_SIGNATURE_CHECK" != "true" && "$SIGNATURE_STATUS" != "G" ]]; then
fi
BRANCH=backport-pr-${PRNUM}
-RANGE=$(git log master --grep "Merge PR #${PRNUM}" --format="%P" | sed 's/ /../')
-MESSAGE=$(git log master --grep "Merge PR #${PRNUM}" --format="%s" | sed 's/Merge/Backport/')
+RANGE=$(git log $MASTER --grep "Merge PR #$PRNUM" --format="%P" | sed 's/ /../')
+MESSAGE=$(git log $MASTER --grep "Merge PR #$PRNUM" --format="%s" | sed 's/Merge/Backport/')
-if git checkout -b "${BRANCH}"; then
+if [[ "$(git rev-parse --abbrev-ref HEAD)" == "$BRANCH" ]]; then
+
+ if ! git cherry-pick --continue; then
+ echo "Please fix the conflicts, then relaunch the script."
+ exit 1
+ fi
+ git checkout -
+
+elif git checkout -b "$BRANCH"; then
if ! git cherry-pick -x "${RANGE}"; then
if [[ "$NO_CONFLICTS" == "true" ]]; then
@@ -61,12 +71,8 @@ if git checkout -b "${BRANCH}"; then
git branch -d "$BRANCH"
exit 1
fi
- echo "Please fix the conflicts, then exit."
- bash
- while ! git cherry-pick --continue; do
- echo "Please fix the conflicts, then exit."
- bash
- done
+ echo "Please fix the conflicts, then relaunch the script."
+ exit 1
fi
git checkout -