3 # https://sourceware.org/bugzilla/show_bug.cgi?id=26034
4 export "BUP_ARGV_0"="$0"
7 export "BUP_ARGV_${arg_i}"="$arg"
11 # Here to end of preamble replaced during install
12 bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
13 exec "$bup_python" "$0"
17 from __future__ import absolute_import, print_function
18 import os.path, re, sys
20 sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
22 from bup import compat, options, version
24 version_rx = re.compile(r'^[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9]+-g[0-9abcdef]+)?$')
27 bup version [--date|--commit|--tag]
29 date display the date this version of bup was created
30 commit display the git commit id of this version of bup
31 tag display the tag name of this version. If no tag is available, display the commit id
33 o = options.Options(optspec)
34 opt, flags, extra = o.parse(compat.argv[1:])
37 total = (opt.date or 0) + (opt.commit or 0) + (opt.tag or 0)
39 o.fatal('at most one option expected')
43 """Format bup's version date string for output."""
44 return version.DATE.split(' ')[0]
48 """Get the commit hash of bup's current version."""
53 """Format bup's version tag (the official version number).
55 When generated from a commit other than one pointed to with a tag, the
56 returned string will be "unknown-" followed by the first seven positions of
59 names = version.NAMES.strip()
60 assert(names[0] == '(')
61 assert(names[-1] == ')')
63 l = [n.strip() for n in names.split(',')]
65 if n.startswith('tag: ') and version_rx.match(n[5:]):
67 return 'unknown-%s' % version.COMMIT[:7]
73 print(version_commit())