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