-
Notifications
You must be signed in to change notification settings - Fork 152
/
git-unreleased
executable file
·43 lines (37 loc) · 959 Bytes
/
git-unreleased
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
#!/bin/bash
# Usage: git unreleased
#
# Shows git commits since the last tagged version.
#
# If library code appears to be contained in `lib` or `libexec` directories,
# show changes pertaining to just that code.
set -e
paths=""
num_libfiles="$(git ls-files -- lib libexec | wc -l)"
if [ $num_libfiles -gt 0 ]; then
paths="bin lib libexec"
fi
format='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ar)%Creset'
show_log() {
git log --graph --format="$format" ${1:+${1}..} -- $paths
}
desc="$(git describe --tags HEAD 2>/dev/null)" || {
echo "no releases exist; showing all changes"
show_log
exit
}
# check for "<tag>-<num_commits>-<sha>" format
if [[ "$desc" == *-*-g* ]]; then
tag_with_num="${desc%-*}"
num_commits="${tag_with_num##*-}"
tag="${tag_with_num%-*}"
else
num_commits=0
tag="$desc"
fi
if [ $num_commits -gt 0 ]; then
echo "${num_commits} commits since ${tag}"
show_log "$tag"
else
echo "no commits since ${tag}"
fi