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
|
#!/bin/sh
set -e
# Generate likely source tarball name for git snapshot from latest commit.
revspec=${1:-HEAD}
cleanup () {
if [ $revspec != "HEAD" ]; then
git checkout master >/dev/null 2>/dev/null
fi
}
sort_options=""
git_tag_options=""
if [ "$revspec" = "HEAD" ]; then
sort_options="-rV"
git_tag_options=""
else
git checkout $revspec >/dev/null 2>/dev/null
sort_options="-V"
git_tag_options="--contains $revspec"
fi
except="THIS_STRING_SHOULD_NOT_EXIST"
if pwd | grep -qc glib; then
except="${except}\|EAZEL"
fi
configured_version=""
latest_tag=`git tag $git_tag_options | grep -v $except | grep '[0-9]' | sed 's/^[^0-9]\+\([0-9]\)/\1/g; s/_$//g; y/_/./; s/.RELEASE//g; s/\(\.\|-\)\([^0-9]\+\)/~\\2/' | sort $sort_options | head -1`
commit_date=`git log -1 --pretty="tformat:%ci" $revspec | sed 's/\([-:]\| [-+]\?[0-9]\{4,4\}\)//g' | tr ' ' '.'`
commit_id=`git log -1 --pretty="%h" $revspec`
date_and_commit_id="${commit_date}.${commit_id}"
if [ "x${latest_tag}" = "x" ]; then
latest_tag=0.0.0
fi
if [ -f configure.ac ]; then
configured_version=`autoconf configure.ac 2>/dev/null | grep 'PACKAGE_VERSION=' | awk -F\' '{ print $2; }'`
fi
if [ "x$configured_version" != "x" ]; then
higher_version=`echo "${latest_tag}\n${configured_version}" | sort -rV | head -1`
if [ "$latest_tag" = "$configured_version" ]; then
if [ "$revspec" = "HEAD" ]; then
tarball_name="${latest_tag}+${date_and_commit_id}"
else
tarball_name="${latest_tag}~${date_and_commit_id}"
fi
else
if [ "$higher_version" = "${configured_version}" ]; then
tarball_name="${configured_version}~${date_and_commit_id}"
elif [ "$higher_version" = "${latest_tag}" ]; then
tarball_name="${configured_version}+${date_and_commit_id}"
else
cleanup
exit 1
fi
fi
else
tarball_name="${latest_tag}+${date_and_commit_id}"
fi
echo $tarball_name
cleanup
exit 0
|