Skip to content

Commit 897c765

Browse files
committed
Merge #251: Update sync-upstream with master
7e91936 ci: Always define EXPERIMENTAL variable (Tim Ruffing) 0a99156 sync-upstream.sh: Add "git show --remerge-diff" tip (Tim Ruffing) 9b6a1c3 sync-upstream.sh: Fix position of "-b" option in reproduce command (Tim Ruffing) 05b207e sync-upstream: allows providing the local branch via cli (Jonas Nick) Pull request description: ACKs for top commit: real-or-random: utACK 7e91936 Tree-SHA512: 4527cb6a2493d210eb7ba6d8f6e717b2acbc07aebdc1c4011cffe23490876a4e795d656a69df2cd50e4e3fe8742c123d9ea493914c148c8fbc93d7d3799e7447
2 parents 7aa9887 + 7e91936 commit 897c765

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
WITH_VALGRIND: yes
1616
EXTRAFLAGS:
1717
### secp256k1 modules
18+
EXPERIMENTAL: no
1819
ECDH: no
1920
RECOVERY: no
2021
SCHNORRSIG: no

contrib/sync-upstream.sh

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
set -eou pipefail
44

55
help() {
6-
echo "$0 range [end]"
7-
echo " merges every merge commit present in upstream and missing locally."
6+
echo "$0 [-b <branch>] range [end]"
7+
echo " merges every merge commit present in upstream and missing in <branch> (default: master)."
88
echo " If the optional [end] commit is provided, only merges up to [end]."
9+
echo " If the optional [-b branch] provided, then ."
910
echo
10-
echo "$0 select <commit> ... <commit>"
11-
echo " merges every selected merge commit"
11+
echo "$0 [-b <branch>] select <commit> ... <commit>"
12+
echo " merges every selected merge commit into <branch> (default: master)"
1213
echo
1314
echo "This tool creates a branch and a script that can be executed to create the"
1415
echo "PR automatically. The script requires the github-cli tool (aka gh)."
@@ -17,12 +18,9 @@ help() {
1718
exit 1
1819
}
1920

20-
if [ "$#" -lt 1 ]; then
21-
help
22-
fi
23-
2421
REMOTE=upstream
2522
REMOTE_BRANCH="$REMOTE/master"
23+
LOCAL_BRANCH="master"
2624
# Makes sure you have a remote "upstream" that is up-to-date
2725
setup() {
2826
ret=0
@@ -41,7 +39,7 @@ setup() {
4139
}
4240

4341
range() {
44-
RANGESTART_COMMIT=$(git merge-base "$REMOTE_BRANCH" master)
42+
RANGESTART_COMMIT=$(git merge-base "$REMOTE_BRANCH" "$LOCAL_BRANCH")
4543
RANGEEND_COMMIT=$(git rev-parse "$REMOTE_BRANCH")
4644
if [ "$#" = 1 ]; then
4745
RANGEEND_COMMIT=$1
@@ -57,18 +55,37 @@ range() {
5755
esac
5856
}
5957

58+
# Process -b <branch> argument
59+
while getopts "b:" opt; do
60+
case $opt in
61+
b)
62+
LOCAL_BRANCH=$OPTARG
63+
;;
64+
\?)
65+
echo "Invalid option: -$OPTARG" >&2
66+
;;
67+
esac
68+
done
69+
70+
# Shift off the processed options
71+
shift $((OPTIND -1))
72+
73+
if [ "$#" -lt 1 ]; then
74+
help
75+
fi
76+
6077
case $1 in
6178
range)
6279
shift
6380
setup
6481
range "$@"
65-
REPRODUCE_COMMAND="$0 range $RANGEEND_COMMIT"
82+
REPRODUCE_COMMAND="$0 -b $LOCAL_BRANCH range $RANGEEND_COMMIT"
6683
;;
6784
select)
6885
shift
6986
setup
7087
COMMITS=$*
71-
REPRODUCE_COMMAND="$0 select $@"
88+
REPRODUCE_COMMAND="$0 -b $LOCAL_BRANCH select $@"
7289
;;
7390
help)
7491
help
@@ -87,16 +104,15 @@ do
87104
done
88105
# Remove trailing ","
89106
TITLE=${TITLE%?}
90-
91-
BODY=$(printf "%s\n\n%s" "$BODY" "This PR can be recreated with \`$REPRODUCE_COMMAND\`.")
107+
BODY=$(printf "%s\n\n%s\n%s" "$BODY" "This PR can be recreated with \`$REPRODUCE_COMMAND\`." "Tip: Use \`git show --remerge-diff\` to show the changes manually added to the merge commit.")
92108

93109
echo "-----------------------------------"
94110
echo "$TITLE"
95111
echo "-----------------------------------"
96112
echo "$BODY"
97113
echo "-----------------------------------"
98114
# Create branch from PR commit and create PR
99-
git checkout master
115+
git checkout "$LOCAL_BRANCH"
100116
git pull --autostash
101117
git checkout -b temp-merge-"$PRNUM"
102118

@@ -115,7 +131,7 @@ cat <<EOT > "$FNAME"
115131
#!/bin/sh
116132
gh pr create -t '$TITLE' -b '$BODY' --web
117133
# Remove temporary branch
118-
git checkout master
134+
git checkout "$LOCAL_BRANCH"
119135
git branch -D temp-merge-"$PRNUM"
120136
EOT
121137
chmod +x "$FNAME"

0 commit comments

Comments
 (0)