Merge lp:~jelmer/bzr-builder/strip-dfsg into lp:bzr-builder

Proposed by Jelmer Vernooij on 2012-03-25
Status: Merged
Approved by: James Westby on 2012-03-26
Approved revision: 168
Merged at revision: 168
Proposed branch: lp:~jelmer/bzr-builder/strip-dfsg
Merge into: lp:bzr-builder
Diff against target: 84 lines (+38/-3)
2 files modified
deb_version.py (+12/-3)
tests/test_deb_version.py (+26/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builder/strip-dfsg
Reviewer Review Type Date Requested Status
James Westby 2012-03-25 Approve on 2012-03-26
Review via email: mp+99204@code.launchpad.net

Description of the change

Drop the dfsg suffix from versions when expanding {debupstream-base}.

To post a comment you must log in.
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deb_version.py'
2--- deb_version.py 2011-12-15 17:08:16 +0000
3+++ deb_version.py 2012-03-25 12:23:18 +0000
4@@ -88,16 +88,25 @@
5 "No previous changelog to take the version from")
6 return str(self._version)
7
8+dfsg_regex = lazy_regex.lazy_compile(
9+ r'[+.]*dfsg[.]*[0-9]+')
10+
11+version_regex = lazy_regex.lazy_compile(
12+ r'([~+])(svn[0-9]+|bzr[0-9]+|git[0-9a-f]+)')
13+
14+def version_extract_base(version):
15+ version = dfsg_regex.sub("", version)
16+ return version_regex.sub("\\1", version)
17+
18
19 class DebUpstreamBaseVariable(DebUpstreamVariable):
20
21 basename = "debupstream-base"
22- version_regex = lazy_regex.lazy_compile(r'([~+])(svn[0-9]+|bzr[0-9]+|git[0-9a-f]+)')
23 minimum_format = 0.4
24
25 def get(self):
26 version = super(DebUpstreamBaseVariable, self).get()
27- version = self.version_regex.sub("\\1", version)
28+ version = version_extract_base(version)
29 if version[-1] not in ("~", "+"):
30 version += "+"
31 return version
32@@ -169,7 +178,7 @@
33 if cl_file_id is not None:
34 tree.lock_read()
35 try:
36- cl = changelog.Changelog(tree.get_file(cl_file_id))
37+ cl = changelog.Changelog(tree.get_file_text(cl_file_id))
38 substitute_changelog_vars(base_branch, branch_name, cl)
39 finally:
40 tree.unlock()
41
42=== modified file 'tests/test_deb_version.py'
43--- tests/test_deb_version.py 2011-12-15 17:32:56 +0000
44+++ tests/test_deb_version.py 2012-03-25 12:23:18 +0000
45@@ -29,6 +29,7 @@
46 DebVersionVariable,
47 SubstitutionUnavailable,
48 check_expanded_deb_version,
49+ version_extract_base,
50 substitute_branch_vars,
51 substitute_time,
52 )
53@@ -313,6 +314,31 @@
54 self.assertEquals("2.4+", var.get())
55
56
57+class VersionExtractBaseTests(TestCase):
58+
59+ def test_simple_extract(self):
60+ self.assertEquals("2.4", version_extract_base("2.4"))
61+ self.assertEquals("2.4+foobar", version_extract_base("2.4+foobar"))
62+
63+ def test_with_bzr(self):
64+ self.assertEquals("2.4+", version_extract_base("2.4+bzr32"))
65+ self.assertEquals("2.4~", version_extract_base("2.4~bzr32"))
66+
67+ def test_with_git(self):
68+ self.assertEquals("2.4+", version_extract_base("2.4+git20101010"))
69+ self.assertEquals("2.4~", version_extract_base("2.4~gitaabbccdd"))
70+
71+ def test_with_svn(self):
72+ self.assertEquals("2.4+", version_extract_base("2.4+svn45"))
73+ self.assertEquals("2.4~", version_extract_base("2.4~svn45"))
74+
75+ def test_with_dfsg(self):
76+ self.assertEquals("2.4+", version_extract_base("2.4+bzr32+dfsg1"))
77+ self.assertEquals("2.4~", version_extract_base("2.4~bzr32+dfsg.1"))
78+ self.assertEquals("2.4~", version_extract_base("2.4~bzr32.dfsg.1"))
79+ self.assertEquals("2.4~", version_extract_base("2.4~bzr32dfsg.1"))
80+
81+
82 class DebVersionVariableTests(TestCase):
83
84 def write_changelog(self, version):

Subscribers

People subscribed via source and target branches