3 from bup import options
4 from bup import _version
7 bup version [--date|--commit|--tag]
9 date display the date this version of bup was created
10 commit display the git commit id of this version of bup
11 tag display the tag name of this version. If no tag is available, display the commit id
13 o = options.Options(optspec)
14 (opt, flags, extra) = o.parse(sys.argv[1:])
17 total = (opt.date or 0) + (opt.commit or 0) + (opt.tag or 0)
19 o.fatal('at most one option expected')
23 """Format bup's version date string for output."""
24 return _version.DATE.split(' ')[0]
28 """Get the commit hash of bup's current version."""
29 return _version.COMMIT
33 """Format bup's version tag (the official version number).
35 When generated from a commit other than one pointed to with a tag, the
36 returned string will be "unknown-" followed by the first seven positions of
39 names = _version.NAMES.strip()
40 assert(names[0] == '(')
41 assert(names[-1] == ')')
43 l = [n.strip() for n in names.split(',')]
45 if n.startswith('tag: bup-'):
47 return 'unknown-%s' % _version.COMMIT[:7]
53 print version_commit()