blob: 62721b047912c7b692b9aadfe719ec7cb473e24c (
plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#!/bin/bash
# pr-create:
#
# Create a Pull Request and send it to Linus Torvalds
#
# This script:
#
# - Craft a PR and put in an email to Linus.
# - Generate a list of patches in short-form
#
# REMOTE: git remote repo the patches are in
# TGT_BRANCH: Branch to generate the pull request against
REMOTE="xfs-linux"
TGT_BRANCH="linus/master"
#Email headers
RECIPIENT="[email protected]"
SUBJECT=""
# Email tool
NEOMUTT=$(which neomutt)
MUTT_CONFIG="$HOME/.mutt/muttrc-Kernel"
#temp files
PULL_FILE=$(mktemp)
MSG_FILE=$(mktemp)
#We accept a single argument
TAG=$1
_die() {
echo "${1}..."
usage
exit 1
}
usage() {
echo "usage: pr-create <tag>"
}
check_email() {
if [ -z $NEOMUTT ]; then
_die "No neomutt found"
fi
if [ -z $MUTT_CONFIG ] || [ ! -f $MUTT_CONFIG ]; then
_die "Please ensure MUTT_CONFIG var is properly set"
fi
}
fixes_setup() {
local V=$1
local R=$2
SUBJECT="[GIT PULL] XFS: Fixes for v$V-$R"
}
merge_setup() {
local V=$1
SUBJECT="[GIT PULL] XFS: New code for v$V"
}
verify_tag() {
local T=$1
git tag --verify $T &> /dev/null
RES=$?
if [ $RES -gt 0 ]; then
echo "Tag: $T"
_die "Verificaiton failed. Does the tag exist?"
fi
}
generate_pull() {
local T=$1
git request-pull $TGT_BRANCH $REMOTE $T &> $PULL_FILE
local res=$?
if [ $res -gt 0 ]; then
local ret=$(head -5 $PULL_FILE)
echo "Unable to create pull request:"
_die "$ret"
fi
}
craft_message() {
local PR=$(cat $1)
cat << ENDL
Hello Linus,
Could you please pull patches included in the tag below?
An attempt merge against your current TOT has been successful.
Thanks,
Carlos
"${PR}"
ENDL
}
generate_email() {
neomutt -F "${MUTT_CONFIG}" -s "$1" -i "$2" "${RECIPIENT}"
}
check_email
TYPE=$(echo $TAG | sed 's/xfs-//' | awk '{split($0, a, "-"); print a[1]}')
VER=$(echo $TAG | sed 's/xfs-//' | awk '{split($0, a, "-"); print a[2]}')
RC=$(echo $TAG | sed 's/xfs-//' | awk '{split($0, a, "-"); print a[3]}')
if [ $TYPE = "merge" ] && [ $RC ]; then
_die "Can't have a -RC tag with a merge tag"
fi
if [ $TYPE = "fixes" ] && [ -z $RC ]; then
_die "A Fixes tag requires a -RC version"
fi
case $TYPE in
"fixes") fixes_setup $VER $RC;;
"merge") merge_setup $VER;;
*) _die "Invalid tag"
esac
verify_tag $TAG
generate_pull $TAG
MSG=$(craft_message $PULL_FILE)
echo "$MSG" > $MSG_FILE
generate_email "$SUBJECT" "$MSG_FILE"
rm $MSG_FILE
rm $PULL_FILE
|