mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
Add cherry-pick.sh convenience script.
This commit is contained in:
parent
700b64e100
commit
adc8cd3e62
34
src/tools/cherry-pick.sh
Executable file
34
src/tools/cherry-pick.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
print_error() {
|
||||
echo "Error: \`$1\` is not a valid commit. To debug, run:"
|
||||
echo
|
||||
echo " git rev-parse --verify $1"
|
||||
echo
|
||||
}
|
||||
|
||||
full_sha() {
|
||||
git rev-parse \
|
||||
--verify \
|
||||
--quiet \
|
||||
"$1^{object}" || print_error $1
|
||||
}
|
||||
|
||||
commit_message_with_backport_note() {
|
||||
message=$(git log --format=%B -n 1 $1)
|
||||
echo $message | awk "NR==1{print; print \"\n(backport-of: $1)\"} NR!=1"
|
||||
}
|
||||
|
||||
cherry_pick_commit() {
|
||||
sha=$(full_sha $1)
|
||||
git cherry-pick $sha > /dev/null
|
||||
git commit \
|
||||
--amend \
|
||||
--file <(commit_message_with_backport_note $sha)
|
||||
}
|
||||
|
||||
for arg ; do
|
||||
cherry_pick_commit $arg
|
||||
done
|
Loading…
Reference in New Issue
Block a user