

from bup import source_info
try:
    from bup import checkout_info
except ImportError:
    checkout_info = None

if checkout_info:
    date = checkout_info.date.encode('ascii')
    commit = checkout_info.commit.encode('ascii')
    modified = checkout_info.modified
else: # presumably an archive with expanded source_info
    date = source_info.date.encode('ascii')
    commit = source_info.commit.encode('ascii')
    modified = source_info.modified
    assert not date.startswith(b'$Format')
    assert not commit.startswith(b'$Format')

# The ~ in a version is a Debian-style "always less than" marker:
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
base_version = b'0.34'

version = base_version
if version.endswith(b'~'):
    version += commit

if modified:
    version += b'+'
