Skip to content

Commit 7e1a983

Browse files
authored
Merge pull request #185 from hashicorp/split-cherry-pick-script
split cherry-pick script
2 parents e664f5b + eb957bb commit 7e1a983

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

scripts/cherry_pick/cherry_pick.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,5 @@ do
2525
git checkout -- "$f"
2626
done
2727

28-
COMMIT_MSG=$(git log --format=%B -n 1 "$COMMIT_ID" | sed -z -r 's/Merge pull request (#[0-9]+) from ([^\n]*\/[^\n]*)\n\n(.*$)/\3\nThis commit was generated from hashicorp\/terraform\1./g')
29-
3028
echo "Committing changes. If this fails, you must resolve the merge conflict manually."
31-
git commit -C "$COMMIT_ID" && \
32-
# amend commit message afterwards to preserve authorship information
33-
git commit --amend --message "${COMMIT_MSG}" \
34-
&& echo "Success!"
29+
./scripts/cherry_pick/commit.sh $COMMIT_ID && echo "Success!"

scripts/cherry_pick/commit.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 1 ]; then
4+
echo "Usage: ./scripts/cherry_pick/commit.sh MERGE_COMMIT_HASH"
5+
fi
6+
7+
function pleaseUseGNUsed {
8+
echo "Please install GNU sed to your PATH as 'sed'."
9+
exit 1
10+
}
11+
sed --version > /dev/null || pleaseUseGNUsed
12+
13+
COMMIT_ID=$1
14+
15+
COMMIT_MSG=$(git log --format=%B -n 1 "$COMMIT_ID" | \
16+
sed -z -r 's/Merge pull request (#[0-9]+) from ([^\n]*\/[^\n]*)\n\n(.*$)/\3\nThis commit was generated from hashicorp\/terraform\1./g')
17+
18+
git commit -C "$COMMIT_ID" && \
19+
# amend commit message afterwards to preserve authorship information
20+
git commit --amend --message "${COMMIT_MSG}"

0 commit comments

Comments
 (0)