-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcranky-commit-hints
More file actions
executable file
·68 lines (58 loc) · 1.1 KB
/
cranky-commit-hints
File metadata and controls
executable file
·68 lines (58 loc) · 1.1 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
#!/bin/bash -eu
#
# Commit an ADT hints file
#
function usage()
{
cat <<EOF
Usage: $(basename "${0}") [-h] HINTS
Commit an ADT hints file.
Optional arguments:
-h, --help Show this help text and exit.
EOF
}
hints=
while [ ${#} -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
*)
if [ -n "${hints}" ] ; then
echo "Invalid argument: ${1}" >&2
exit 2
fi
hints=${1}
;;
esac
shift
done
if [ -z "${hints}" ] ; then
usage
exit 2
fi
readarray -t vals < <(git diff "${hints}" | grep "^+result" | tail -1 | \
tr ' ' '\n')
series=${vals[1]}
name=${vals[2]/-meta/}
name=${name#linux-}
version=${vals[3]}
pkg=${vals[4]}
m=$(git diff "${hints}" | grep -c "^-result" || true)
p=$(git diff "${hints}" | grep -c "^+result" || true)
case "${m}-${p}" in
0-1)
subject="${series::1}/${name}: hint ${pkg} for ${version}"
;;
0-*)
subject="${series::1}/${name}: hints for ${version}"
;;
1-1)
subject="${series::1}/${name}: fix ${pkg} hint for ${version}"
;;
*-*)
subject="${series::1}/${name}: fix hints for ${version}"
;;
esac
git commit -s -m "${subject}" -- "${hints}"