-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcranky-git-logs
More file actions
executable file
·83 lines (71 loc) · 1.59 KB
/
cranky-git-logs
File metadata and controls
executable file
·83 lines (71 loc) · 1.59 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
#!/bin/bash -eu
function pr_banner()
{
local txt
if [ -z "${__COLS:-}" ] ; then
__COLS=$(tput cols)
fi
txt=${*}$(printf "%${__COLS}s")
echo -e "\033[48;5;160m${txt::${__COLS}}\033[0m"
}
function usage()
{
cat <<EOF
Usage: $(basename "${0}") [-h] [-l] [GIT_LOG_OPTIONS]
Show kernel source git repo logs.
Optional arguments:
-h, --help Show this help message and exit.
-l, --local Show local changes, i.e., changes between origin and
local HEAD.
-r, --release NUM Show change since previous NUM releases.
EOF
}
CRANKY=${CRANKY:-cranky}
local=0
release=0
while [ ${#} -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
-l|--local)
local=1
;;
-r|--release)
shift
release=${1}
;;
*)
break
;;
esac
shift
done
if [ ${local} -ne 0 ] && [ "${release}" -ne 0 ] ; then
usage
exit 2
fi
while IFS= read -r path ; do
echo
pr_banner "${path}"
cd "${path}"
rev_range=()
if [ ${local} -eq 1 ] ; then
# shellcheck disable=SC1083
rtb=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
subject=$(git log --format=%s "${rtb}" -1)
m=$(git log --format="%h ___%s___" -1000 | \
grep -m1 -F "___${subject}___" || true)
if [ -n "${m}" ] ; then
rev_range=("${m%% *}..")
fi
elif [ "${release}" -gt 0 ] ; then
m=$(git log --format="%h ___%s" HEAD~1 | \
grep -m"${release}" -F "__UBUNTU: Ubuntu-" | tail -1)
if [ -n "${m}" ] ; then
rev_range=("${m%% *}~1..")
fi
fi
git --no-pager log --color=always --decorate=short "${@}" "${rev_range[@]}"
done < <("${CRANKY}" shell-helper source-packages-path) | less