-
Notifications
You must be signed in to change notification settings - Fork 240
/
list-version-hashes
executable file
·77 lines (64 loc) · 1.64 KB
/
list-version-hashes
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
#!/bin/bash
# M.Blakeney, Oct 2018.
PROG="$(basename $0)"
PROGDIR="$(dirname $0)"
SUMPROG="md5sum"
MAINPROG="libinput-gestures"
usage() {
echo "Usage: $PROG [-options] [hashsum]"
echo "Development utility to list version and hash sums, and flag those that"
echo "match given hash sum. Must be run from the $MAINPROG git repo dir."
echo "Options:"
echo "-o (use old hash calc)"
exit 1
}
# Process command line options
OLDCALC=0
while getopts o\? c; do
case $c in
o) OLDCALC=1;;
\?) usage;;
esac
done
shift $((OPTIND - 1))
if [[ $# -eq 1 ]]; then
HASHSUM="$1"
elif [[ $# -ne 0 ]]; then
usage
else
HASHSUM=""
fi
output() {
local tag=$1
local hashsum=${2/ */}
if [[ -n $HASHSUM && $HASHSUM == $hashsum ]]; then
found=" *"
else
found=""
fi
printf "%-24s %s%s\n" $tag $hashsum "$found"
}
cd ${PROGDIR:-.} || exit 1
# Iterate through all tags and output the md5 hash for each version
tag=""
while read hashc; do
tag=$(git describe --tags --always $hashc)
filelist="$hashc:$MAINPROG"
if [[ $OLDCALC -eq 0 ]]; then
filelist2="$hashc:$MAINPROG-setup"
# Check the setup file exists in this (potentially old) commit
if git cat-file -t "$filelist2" &>/dev/null; then
filelist="$filelist $filelist2"
fi
fi
output $tag "$(git show $filelist | $SUMPROG)"
done <<< "$(git rev-list --all --reverse)"
# Output a version for the working tree as well
tagw=$(git describe --tags --always --dirty)
if [[ $tagw != $tag ]]; then
if [[ $OLDCALC -eq 0 ]]; then
output $tagw "$(cat $MAINPROG $MAINPROG-setup | $SUMPROG)"
else
output $tagw "$($SUMPROG <$MAINPROG)"
fi
fi