-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-by
executable file
·80 lines (68 loc) · 1.56 KB
/
x-by
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#
# Add *-by for specific commit, used for cherry-picked
# tb - Tested-by
# rob - Reviewed-by
# sob - Signed-off-by
# ack - Acked-by
if [ "$#" -gt 3 ]; then
echo "Usage: x by <tb|rob|sob|ack> <name> <commit sha1>"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
BY_TAG=""
if [ "$#" -gt 0 ]; then
if [ "$1" == "tb" ]; then
BY_TAG="Tested-by"
fi
if [ "$1" == "rob" ]; then
BY_TAG="Reviewed-by"
fi
if [ "$1" == "sob" ]; then
BY_TAG="Signed-off-by"
fi
if [ "$1" == "ack" ]; then
BY_TAG="Acked-by"
fi
if [ "$1" == "rep" ]; then
BY_TAG="Reported-by"
fi
fi
if [ r"$BY_TAG" == r"" ]; then
echo "Please provide type of -by"
echo " tb - Tested-by"
echo " rob - Reviewed-by"
echo " sob - Signed-off-by"
echo " ack - Acked-by"
echo " rep - Reported-by"
exit
fi
if [ "$#" -gt 1 ]; then
if [ $(grep -c "alias $2" $MUTTAL ) -eq 0 ]; then
echo "There is no such name in $MUTTAL"
exit
fi
BY="$BY_TAG: $(grep -m 1 "alias $2" $MUTTAL | cut -d' ' -f 3-)"
else
echo "Please provide name for $BY_TAG"
echo "The data is taken from $MUTTAL"
exit
fi
if [ "$#" -gt 2 ]; then
IN=$3
else
IN="HEAD"
fi
PREV=$IN^1
set -e
PRTMP=$(mktemp -d)
git format-patch -M -C --no-cover-letter --no-signoff -o $PRTMP/ $PREV
sed -i -e '/^Issue:[ 0-9]*/Id' -e '/^Change-id:[ 0-9]*/Id' $PRTMP/0001-*
tac $PRTMP/0001-* > $PRTMP/tac.tmp
sed -i "0,/Signed-off-by: /s//$BY\nSigned-off-by: /" $PRTMP/tac.tmp
tac $PRTMP/tac.tmp > $PRTMP/0001-*
git reset --hard $PREV
git am --signoff $PRTMP/0001-*
rm -rf $PRTMP