-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-cp
executable file
·54 lines (45 loc) · 1.37 KB
/
x-cp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# Special version of cherry-pick from gerrit.
# It removes Issue, changeid, runs checkpatch and add reviewed-by tags.
# It works on rdma-rc/rdma-next branches only.
#
if [ "$#" -ne 1 ]; then
echo "Usage: x cp <commit sha1>"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
IN=$1
TARGET=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ "$TARGET" != "rdma-next" ] && [ "$TARGET" != "rdma-rc" ]; then
echo "It works on rdma-next or rdma-rc branches. Exiting...."
exit
fi
if [[ $IN != *".."* ]]; then
IN="-1 $IN"
fi
PRTMP=$(mktemp -d)
git format-patch -M -C --no-cover-letter -s -o $PRTMP/ $IN
for file in $PRTMP/*.patch; do
CHANGEID=$(grep -i change-id $file | awk '{print $2}')
ROB=$(ssh -x -p 29418 gerrit.mtl.com gerrit query --all-approvals change:$CHANGEID| \
grep "type: Code-Review" -A 6 | \
grep "value: 1" -A 4 | \
grep "email\|name" | \
sort -u)
if [ "r$ROB" != "r" ]; then
ROB=$(echo $ROB | awk '{print "Reviewed-by: " $4 " " $5 " <" $2 ">"}')
echo $ROB
fi
sed -i -e '/^Issue:[ 0-9]*/Id' -e '/^Change-id:[ 0-9]*/Id' $file
sed -i "0,/Signed-off-by: Leon Romanovsky <[email protected]>/s//$ROB\nSigned-off-by: Leon Romanovsky <[email protected]>/" $file
done
get_project $PWD
PROJECT=$REPLY
checkpatch $PRTMP/ $PROJECT
git am $PRTMP/*
if [ $? -eq 0 ]; then
rm -fr $PRTMP
fi