3 bup_python="$(dirname "$0")/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
8 from __future__ import absolute_import, print_function
11 from bup import options
12 from bup import version
14 version_rx = re.compile(r'^[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9]+-g[0-9abcdef]+)?$')
17 bup version [--date|--commit|--tag]
19 date display the date this version of bup was created
20 commit display the git commit id of this version of bup
21 tag display the tag name of this version. If no tag is available, display the commit id
23 o = options.Options(optspec)
24 (opt, flags, extra) = o.parse(sys.argv[1:])
27 total = (opt.date or 0) + (opt.commit or 0) + (opt.tag or 0)
29 o.fatal('at most one option expected')
33 """Format bup's version date string for output."""
34 return version.DATE.split(' ')[0]
38 """Get the commit hash of bup's current version."""
43 """Format bup's version tag (the official version number).
45 When generated from a commit other than one pointed to with a tag, the
46 returned string will be "unknown-" followed by the first seven positions of
49 names = version.NAMES.strip()
50 assert(names[0] == '(')
51 assert(names[-1] == ')')
53 l = [n.strip() for n in names.split(',')]
55 if n.startswith('tag: ') and version_rx.match(n[5:]):
57 return 'unknown-%s' % version.COMMIT[:7]
63 print(version_commit())