-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupload-patch
executable file
·75 lines (63 loc) · 1.4 KB
/
upload-patch
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
#!/bin/sh
usage()
{
cat <<__EOF__
Usage: $(basename $0) [ -b <branch> ] [ -p <parent-branch> ]
Options:
-b <branch> -- Branch head to use. Defaults to the current branch.
-p <parent-branch> -- Parent branch to diff against. Defaults to
markj-kernel-config.
__EOF__
exit 1
}
err()
{
echo "$(basename $0): $1" >&2
exit 1
}
PBRANCH=markj-kernel-config
BRANCH=$(git branch | awk '/^\*/{print $NF}')
if [ $? -ne 0 ]; then
err "couldn't obtain git branch list"
fi
while [ $# -gt 0 ]; do
case $1 in
-b)
shift
BRANCH=$1
;;
-p)
shift
PBRANCH=$1
;;
*)
usage
;;
esac
shift
done
if [ $# -gt 0 ]; then
usage
fi
tmpfile=$(mktemp)
chmod a+r $tmpfile
git diff ${PBRANCH}..${BRANCH} > $tmpfile
less $tmpfile
DIR=patches/${BRANCH#[0-9]*-}
ssh [email protected] "mkdir -p public_html/${DIR}"
COUNTF=$(mktemp)
scp [email protected]:public_html/${DIR}/count $COUNTF 2>/dev/null
if [ $(stat -f "%z" $COUNTF) -eq 0 ]; then
COUNT=1
else
COUNT=$(cat $COUNTF)
COUNT=$(($COUNT + 1))
fi
echo $COUNT > $COUNTF
scp $COUNTF [email protected]:public_html/${DIR}/count
FILE=${DIR}/${BRANCH#[0-9]*-}-${COUNT}.diff
scp $tmpfile [email protected]:public_html/$FILE
if [ $? -ne 0 ]; then
exit 1
fi
echo "http://people.freebsd.org/~markj/${FILE}"