blob: f991d86369fd2b823e955f02dfd7a037aedb950e (
plain)
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
|
#!/usr/bin/env sh
###
### Generate a version number for packaging cpplint
###
start="$PWD"
mirror="$PWD/styleguide.mirror"
working="$PWD/styleguide"
# clone or update mirror styleguide repo
if [ ! -d "$mirror" ]; then
git clone --mirror "https://github.com/google/styleguide" "$mirror"
else
cd "$mirror" || exit
git remote update
cd "$start" || exit
fi
# delete styleguide repo if it exists
if [ -d "$working" ] && [ -d "$working/.git" ]; then
rm -rf "$working"
fi
# clone new styleguide repo
git clone "$mirror" "$working"
cd "$working" || exit
# make new branch
git checkout -b cpplint
# filter cpplint subdirectory
git filter-branch --prune-empty --subdirectory-filter cpplint
# ensure no tags exist
numtags="$(git tag|wc -l)"
if [ "$numtags" -gt 0 ]; then
printf "\n%s" "aborting, some tags already exist"
exit 1
fi
# create tags for commits that mention a revision number
for commit in $(git rev-list cpplint); do
firstline=$(git log --format="%B" -n 1 $commit|head -n1)
revision="$(echo "$firstline"|grep -P -o '(?<=Update cpplint.py to [#r])\d+(?=:|$)')"
if [ $? -eq 0 ]; then
git tag -a "$revision" "$commit" -m "automatically created tag for cpplint $revision"
fi
done
# print latest version
printf "\nlatest version: %s" "$(git describe | sed 's/\([^-]*-\)g/r\1/;s/-/./g'|cut -f 1-2 -d.)"
# clean up
cd "$start" || exit
rm -rf "$working"
|