-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-pr-set
More file actions
executable file
·91 lines (73 loc) · 1.49 KB
/
create-pr-set
File metadata and controls
executable file
·91 lines (73 loc) · 1.49 KB
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
#!/bin/bash -eu
function out()
{
if [ "$(git rev-parse --abbrev-ref HEAD)" != "${CURR_BRANCH}" ] ; then
git checkout "${CURR_BRANCH}"
fi
}
function usage()
{
cat <<EOF
Usage: $(basename "${0}") [-h] BUG
Create a pull-request set targeting different series.
Positional arguments:
BUG LP bug number.
Optional arguments:
-h, --help Show this help text and exit.
EOF
}
bug=
while [ ${#} -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
[0-9]*)
if [ -n "${bug}" ] ; then
echo "Invalid argument: ${1}" >&2
exit 2
fi
bug=${1}
;;
*)
echo "Invalid argument: ${1}" >&2
exit 2
;;
esac
shift
done
if [ -z "${bug}" ] ; then
usage
exit 2
fi
CURR_BRANCH=$(git rev-parse --abbrev-ref HEAD)
trap out EXIT INT TERM HUP
rm -rf .outgoing
mkdir .outgoing
num=0
while IFS= read -r branch ; do
num=$((num + 1))
echo "-- Process ${branch}"
git checkout "${branch}"
# Create the PR
pr_file=$(printf ".outgoing/%04d-%s.pr" "${num}" "${branch//\//-}")
git-deb request-pull > "${pr_file}"
s=${branch##*/}
s=${s::1}
S=${s^^}
if [ ${num} -eq 1 ] ; then
series=${S}
# Create the cover letter
sed -e '/^---/,$d' "${pr_file}" > .outgoing/0000-cover-letter.pr
else
series=${series}/${S}
fi
echo
done < <(git branch | grep "lp${bug}" | cut -c 3- | sort -r)
if [ ${num} -eq 0 ] ; then
echo "No branches found for bug: ${bug}" >&2
exit 1
fi
# Fix the series in the cover letter subject
sed -i -e "s,\[[A-Z]:,[${series}:," .outgoing/0000-cover-letter.pr