As far as I know the Chromium OS team is the only user of this script, so align its output with that of other tools used there: - Replace "Original-Commit-Id" with "GitOrigin-RevId" - Reuse Change-Id instead of moving it to the Original- prefix, which leads to the creation of a new Change ID. Change-Id: I8c39c512901c83a64f00aa48a539e6621f827242 Signed-off-by: Patrick Georgi <patrick@coreboot.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60979 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env sh
 | 
						|
# cross-repo-cherrypick - rebase helper script
 | 
						|
#
 | 
						|
# SPDX-License-Identifier: GPL-2.0-only
 | 
						|
 | 
						|
# Adapt to your remote branch:
 | 
						|
BRANCH="origin/master"
 | 
						|
 | 
						|
# 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 ...
 | 
						|
#  git rebase -i --exec util/scripts/cross-repo-cherrypick master
 | 
						|
# Alternatively, you can run util/scripts/cross-repo-cherrypick after every
 | 
						|
# individual cherry-pick.
 | 
						|
 | 
						|
# use $0 --cros to add a stub BUG/BRANCH/TEST block
 | 
						|
 | 
						|
commit_message() {
 | 
						|
	git log -n 1 | grep "^    " | cut -c5-
 | 
						|
}
 | 
						|
 | 
						|
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
 | 
						|
 | 
						|
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.
 | 
						|
 | 
						|
(printf "${MESSAGE_PREFIX}"; commit_message) | tac | awk '/^$/ {
 | 
						|
		if (end==0) {
 | 
						|
			print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
 | 
						|
			'"${SPLICE_CMD}"'
 | 
						|
		}
 | 
						|
		end=1
 | 
						|
	}; /^(BUG|BRANCH|TEST)=/ {
 | 
						|
		if (end==0) {
 | 
						|
			print "GitOrigin-RevId: '"${CID}"'\nSigned-off-by: '"${GUID}"'";
 | 
						|
			print "";
 | 
						|
		}
 | 
						|
		end=1
 | 
						|
	}; /^Cq-Depend:/ {
 | 
						|
		print $0;
 | 
						|
		next
 | 
						|
	}; /^Change-Id:/ {
 | 
						|
		print $0;
 | 
						|
		next
 | 
						|
	}; {
 | 
						|
		if (end==0)
 | 
						|
			print "Original-" $0;
 | 
						|
		else
 | 
						|
			print $0;
 | 
						|
	}' | tac | git commit --amend -F -
 |