2020-12-24 20:06:38 +01:00
|
|
|
#!/usr/bin/env sh
|
2019-05-17 15:36:47 +02:00
|
|
|
# cross-repo-cherrypick - rebase helper script
|
2015-04-04 02:06:48 +02:00
|
|
|
#
|
util/: Replace GPLv2 boiler plate with SPDX header
Used commands:
perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist)
perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist)
perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
Change-Id: I1008a63b804f355a916221ac994701d7584f60ff
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2015-04-04 02:06:48 +02:00
|
|
|
|
|
|
|
# Adapt to your remote branch:
|
2023-09-12 17:38:19 +02:00
|
|
|
BRANCH="origin/main"
|
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)
|
2023-09-12 17:38:19 +02:00
|
|
|
BRANCH="origin/main"
|
2017-01-13 19:11:29 +01:00
|
|
|
MESSAGE_PREFIX="UPSTREAM: "
|
|
|
|
;;
|
|
|
|
chromium-review.googlesource.com)
|
2023-11-18 04:54:50 +01:00
|
|
|
BRANCH="cros/main"
|
2017-01-13 19:11:29 +01:00
|
|
|
MESSAGE_PREFIX=""
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# lines must be backwards due to tac(1)
|
|
|
|
SPLICE_CMD=""
|
|
|
|
if test "$1" = "--cros"; then
|
2023-04-01 14:42:54 +02:00
|
|
|
if test -z "$(commit_message | grep -E '^(BUG|TEST)=')"; then
|
2017-01-13 19:11:29 +01:00
|
|
|
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) {
|
2022-01-10 22:41:03 +01:00
|
|
|
print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
|
2017-01-13 19:11:29 +01:00
|
|
|
'"${SPLICE_CMD}"'
|
|
|
|
}
|
2015-04-04 02:06:48 +02:00
|
|
|
end=1
|
2020-08-26 20:10:10 +02:00
|
|
|
}; /^(BUG|BRANCH|TEST)=/ {
|
2017-09-14 09:48:35 +02:00
|
|
|
if (end==0) {
|
2022-01-10 22:41:03 +01:00
|
|
|
print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
|
2017-09-14 09:48:35 +02:00
|
|
|
print "";
|
|
|
|
}
|
|
|
|
end=1
|
2020-08-26 20:10:10 +02:00
|
|
|
}; /^Cq-Depend:/ {
|
|
|
|
print $0;
|
|
|
|
next
|
2022-01-10 22:41:03 +01:00
|
|
|
}; /^Change-Id:/ {
|
|
|
|
print $0;
|
|
|
|
next
|
2015-04-04 02:06:48 +02:00
|
|
|
}; {
|
|
|
|
if (end==0)
|
|
|
|
print "Original-" $0;
|
|
|
|
else
|
|
|
|
print $0;
|
|
|
|
}' | tac | git commit --amend -F -
|