55# that can be found in the LICENSE file at the root of the
66# Mumble source tree or at <https://www.mumble.info/LICENSE>.
77#
8- # This script returns the Mumble version string for a Mumble Git
9- # repository. The script must be run from within a Mumble Git
10- # repository.
11- # This is a replacement for `git describe` to make snapshots
12- # use the future, untagged version number rather than the previous.
13- #
14- # The version is of form 1.3.0~2020-07-02~g4f336a2~snapshot.
15- # It includes the target release version rather than the previous
16- # release (as git describe does).
17- #
18- # Detailed description:
19- #
20- # Once upon a time, Mumble used the output of `git describe` as
21- # its version string.
22- #
23- # If a commit was tagged, it was a "release", and got a simple
24- # string which was the name of the tag.
25- #
26- # If a commit wasn't tagged, it got '1.2.6-234-gf552ag1', which
27- # consists of the number of commits since the latest tag, and
28- # the commit hash of the latest commit.
29- #
30- # However, the output of `git describe` was found to be confusing
31- # in practice. This is because the base version of the `git describe`
32- # output is the latest tag, which is to say: the *previous*
33- # version of Mumble.
34- #
35- # So, a user running a snapshot that would become 1.3.0 would be
36- # running a version like 1.2.6-234-gf552ag1. This is confusing
37- # simply by looking at the version numbers, but the way versioning
38- # works inside the Mumble client made it worse: the client's version
39- # was referred to as "1.3.0" in several places, but the actual version
40- # number said 1.2.6-234-gf552ag1.
41- #
42- # This script is the replacement for `git describe`. It outputs the
43- # *actual* base version of the Mumble tree, rather than the latest tag.
44- # This means that snapshots for Mumble 1.3.0 now have the base version
45- # '1.3.0'.
46- #
47- # It also changes the version string: Instead of using dashes
48- # as a separator in the version string, it now uses tildes. This allows
49- # Debian's dpkg version comparer to correctly sort snapshot versions
50- # before release versions. The new string also includes 'snapshot' in the
51- # version string to denote to users that the given version is a pre-release
52- # snapshot.
53- # Furthermore the version number does use the latest commit's date rather
54- # than therevision number since the last tag.
55- # A full new-style version string looks like this:
56- # 1.3.0~2020-07-02~g4f336a2~snapshot.
8+ # This script reads and prints the current Mumble version
579
5810from __future__ import (unicode_literals , print_function , division )
5911
@@ -100,10 +52,7 @@ def readProjectVersion():
10052
10153def main ():
10254 parser = argparse .ArgumentParser ()
103- parser .add_argument ('-f' , '--format' , choices = ['full' , 'version' , 'suffix' ], default = 'full' , help = 'Output format' )
10455 parser .add_argument ('-n' , '--newline' , action = "store_true" , help = 'Break line after printing version' )
105- parser .add_argument ('-r' , '--revision' , type = int , default = 1 , help = 'Revision (only used for type \' beta\' and \' rc\' )' )
106- parser .add_argument ('-t' , '--type' , choices = ['snapshot' , 'beta' , 'rc' , 'stable' ], default = 'snapshot' , help = 'Release type - determines the suffix' )
10756 args = parser .parse_args ()
10857
10958 if args .newline :
@@ -113,27 +62,9 @@ def main():
11362
11463 version = readProjectVersion ()
11564
116- if args .format == 'version' :
117- print (version , end = end )
118- return
119-
120- suffix = ''
65+ print (version , end = end )
12166
122- if args .type == 'rc' or args .type == 'beta' :
123- suffix = '-{0}{1}' .format (args .type , args .revision )
124- elif args .type == 'snapshot' :
125- # Get the date of the most recent commit
126- latestCommitDate = cmd (['git' , 'log' , '-1' , '--format=%cd' , '--date=short' ]).strip ()
12767
128- # Get the hash of the most recent commit (shortened)
129- latestCommitHash = cmd (['git' , 'rev-parse' , '--short' , 'HEAD' ]).strip ()
130-
131- suffix = '~{0}~g{1}~snapshot' .format (latestCommitDate , latestCommitHash )
132-
133- if args .format == 'suffix' :
134- print (suffix , end = end )
135- else :
136- print (version + suffix , end = end )
13768
13869if __name__ == '__main__' :
13970 main ()
0 commit comments