We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 700b64e commit adc8cd3Copy full SHA for adc8cd3
src/tools/cherry-pick.sh
@@ -0,0 +1,34 @@
1
+#!/bin/bash
2
+set -euo pipefail
3
+IFS=$'\n\t'
4
+
5
+print_error() {
6
+ echo "Error: \`$1\` is not a valid commit. To debug, run:"
7
+ echo
8
+ echo " git rev-parse --verify $1"
9
10
+}
11
12
+full_sha() {
13
+ git rev-parse \
14
+ --verify \
15
+ --quiet \
16
+ "$1^{object}" || print_error $1
17
18
19
+commit_message_with_backport_note() {
20
+ message=$(git log --format=%B -n 1 $1)
21
+ echo $message | awk "NR==1{print; print \"\n(backport-of: $1)\"} NR!=1"
22
23
24
+cherry_pick_commit() {
25
+ sha=$(full_sha $1)
26
+ git cherry-pick $sha > /dev/null
27
+ git commit \
28
+ --amend \
29
+ --file <(commit_message_with_backport_note $sha)
30
31
32
+for arg ; do
33
+ cherry_pick_commit $arg
34
+done
0 commit comments