29
26
from debian_bundle.changelog import Version
32
def is_upstream_tag(tag):
33
"""Return true if tag is an upstream tag.
35
:param tag: The string name of the tag.
36
:return: True if the tag name is one generated by upstream tag operations.
38
>>> is_upstream_tag('2.1')
40
>>> is_upstream_tag('upstream-2.1')
43
return tag.startswith('upstream-') or tag.startswith('upstream/')
46
def upstream_tag_version(tag):
47
"""Return the upstream version portion of an upstream tag name.
49
:param tag: The string name of the tag.
50
:return: The version portion of the tag.
52
>>> upstream_tag_version('upstream-2.1')
55
assert is_upstream_tag(tag), "Not an upstream tag: %s" % tag
56
if tag.startswith('upstream/'):
57
tag = tag[len('upstream/'):]
58
elif tag.startswith('upstream-'):
59
tag = tag[len('upstream-'):]
60
if tag.startswith('debian-'):
61
tag = tag[len('debian-'):]
62
elif tag.startswith('ubuntu-'):
63
tag = tag[len('ubuntu-'):]
67
29
def sort_debversion(branch, tags):
68
30
"""Sort tags using Debian version in-place.