-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-stable
executable file
·55 lines (42 loc) · 1.2 KB
/
x-stable
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
#!/bin/bash
#
# Mark specific commit as targeted for stable
if [ "$#" -gt 1 ]; then
echo "Usage: x stable <commit sha1>"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
if [ "$#" -gt 0 ]; then
IN=$1
else
IN="HEAD"
fi
PREV=$IN^1
set -e
FIXES=$(git show $IN | grep Fixes | awk '{print $2}')
get_project $PWD
PROJECT=$REPLY
if [ "$PROJECT" == "kernel" ]; then
if [ "$(git show $IN | grep -c stable\@vger.kernel.org)" -gt 0 ]; then
echo "There is already [email protected] in the commit message. Exiting..."
exit
fi
# We are in kernel repo
TAG=$(git l --author="Linus Torvalds" --no-merges $FIXES..HEAD | grep Linux | awk '{print $3}' | tail -1 | cut -d'-' -f1)
STABLE="Cc: <[email protected]> # $TAG"
fi
if [ "$PROJECT" == "rdma-core" ]; then
if [ "$(git show $IN | grep -c stable\@linux-rdma.org)" -gt 0 ]; then
echo "There is already [email protected] in the commit message. Exiting..."
exit
fi
STABLE="Cc: <[email protected]>"
fi
PRTMP=$(mktemp -d)
git format-patch -M -C --no-cover-letter -s -o $PRTMP/ $PREV
sed -i "/Fixes: /i $STABLE" $PRTMP/0001-*
git reset --hard $PREV
git am $PRTMP/*
rm -rf $PRTMP