2015-04-04 02:06:48 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-05-17 15:36:47 +02:00
|
|
|
# cross-repo-cherrypick - rebase helper script
|
2015-04-04 02:06:48 +02:00
|
|
|
#
|
2017-01-13 19:11:29 +01:00
|
|
|
# Copyright 2015, 2017 Google Inc.
|
2016-10-24 11:58:07 +02:00
|
|
|
#
|
2015-04-04 02:06:48 +02:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Adapt to your remote branch:
|
2017-01-13 19:11:29 +01:00
|
|
|
BRANCH="origin/master"
|
2015-04-04 02:06:48 +02:00
|
|
|
|
|
|
|
# When pulling in patches from another tree from a gerrit repository,
|
|
|
|
# do the following at the end of a larger cherry-pick series:
|
|
|
|
# git remote add ...
|
|
|
|
# git checkout -b upstreaming
|
|
|
|
# git cherry-pick ...
|
2019-05-17 15:36:47 +02:00
|
|
|
# git rebase -i --exec util/scripts/cross-repo-cherrypick master
|
|
|
|
# Alternatively, you can run util/scripts/cross-repo-cherrypick after every
|
2015-04-04 02:06:48 +02:00
|
|
|
# individual cherry-pick.
|
|
|
|
|
2017-01-13 19:11:29 +01:00
|
|
|
# use $0 --cros to add a stub BUG/BRANCH/TEST block
|
|
|
|
|
2015-04-04 02:06:48 +02:00
|
|
|
commit_message() {
|
|
|
|
git log -n 1 | grep "^ " | cut -c5-
|
|
|
|
}
|
|
|
|
|
2017-01-13 19:11:29 +01:00
|
|
|
ORIGIN_HOST=$( commit_message |grep "^Reviewed-on: " |head -1 |cut -d/ -f3 )
|
|
|
|
case "${ORIGIN_HOST}" in
|
|
|
|
review.coreboot.org)
|
|
|
|
BRANCH="origin/master"
|
|
|
|
MESSAGE_PREFIX="UPSTREAM: "
|
|
|
|
;;
|
|
|
|
chromium-review.googlesource.com)
|
|
|
|
BRANCH="cros/chromeos-2016.05"
|
|
|
|
MESSAGE_PREFIX=""
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# lines must be backwards due to tac(1)
|
|
|
|
SPLICE_CMD=""
|
|
|
|
if test "$1" = "--cros"; then
|
|
|
|
if test -z "$( commit_message |egrep '^(BUG|TEST)=')"; then
|
|
|
|
SPLICE_CMD='print "\nTEST=none\nBRANCH=none\nBUG=none\n"'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-04-04 02:06:48 +02:00
|
|
|
CHID=$( commit_message | grep -i "^Change-Id: I" )
|
|
|
|
CID=$( git log -n1 --grep "^$CHID$" --pretty=%H $BRANCH )
|
|
|
|
GUID="$(git config user.name) <$(git config user.email)>"
|
|
|
|
|
|
|
|
# TBD: Don't add Original- to empty lines, and possibly make script more
|
|
|
|
# solid for commits with an unexpected order of meta data lines.
|
|
|
|
|
2017-01-13 19:11:29 +01:00
|
|
|
(printf "${MESSAGE_PREFIX}"; commit_message) | tac | awk '/^$/ {
|
|
|
|
if (end==0) {
|
|
|
|
print "Original-Commit-Id: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
|
|
|
|
'"${SPLICE_CMD}"'
|
|
|
|
}
|
2015-04-04 02:06:48 +02:00
|
|
|
end=1
|
2017-09-14 09:48:35 +02:00
|
|
|
}; /^(BUG|BRANCH|TEST|CQ-DEPEND)=/ {
|
|
|
|
if (end==0) {
|
|
|
|
print "Original-Commit-Id: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
|
|
|
|
print "";
|
|
|
|
}
|
|
|
|
end=1
|
2015-04-04 02:06:48 +02:00
|
|
|
}; {
|
|
|
|
if (end==0)
|
|
|
|
print "Original-" $0;
|
|
|
|
else
|
|
|
|
print $0;
|
|
|
|
}' | tac | git commit --amend -F -
|