Merge ~nacc/git-ubuntu:bugfixes-after-refactor into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Approved by: Nish Aravamudan
Approved revision: dce62ca00595cee0d8f285f0353a33bfb8518199
Merge reported by: Nish Aravamudan
Merged at revision: dce62ca00595cee0d8f285f0353a33bfb8518199
Proposed branch: ~nacc/git-ubuntu:bugfixes-after-refactor
Merge into: git-ubuntu:master
Diff against target: 239 lines (+85/-51)
2 files modified
gitubuntu/git_repository.py (+59/-36)
gitubuntu/versioning.py (+26/-15)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Server Team CI bot continuous-integration Needs Fixing
Review via email: mp+330614@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:3f2aa06526fe716e980ac3766abf673dbfda84b5
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~nacc/usd-importer/+git/usd-importer/+merge/330614/+edit-commit-message

https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/65/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    FAILED: Unit Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/65/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:1c85b9925c2ac4104df77230a81d8d54e98ac16d
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~nacc/usd-importer/+git/usd-importer/+merge/330614/+edit-commit-message

https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/67/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Style Check

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/67/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:05e459aa4164129a398899d605f9e94a0c3e02ba
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~nacc/usd-importer/+git/usd-importer/+merge/330614/+edit-commit-message

https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/69/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    FAILED: Integration Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/69/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:dce62ca00595cee0d8f285f0353a33bfb8518199
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~nacc/usd-importer/+git/usd-importer/+merge/330614/+edit-commit-message

https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/71/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/71/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

+1 with just an optional suggestion. I confess that this module is a bit hard to follow, and I understand that versioning has tons of rules and is complex. Glad that it has tests and that they pass :) (tested on artful)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/git_repository.py b/gitubuntu/git_repository.py
2index 9fdf7bb..7ed7bdb 100644
3--- a/gitubuntu/git_repository.py
4+++ b/gitubuntu/git_repository.py
5@@ -16,6 +16,7 @@ from subprocess import CalledProcessError
6 import sys
7 import tempfile
8 import time
9+from gitubuntu.__main__ import top_level_defaults
10 from gitubuntu.dsc import component_tarball_matches
11 from gitubuntu.run import run, runq, decode_binary
12 try:
13@@ -426,9 +427,14 @@ class GitUbuntuRepository:
14
15 To access the underlying pygit2.Repository object, use the raw_repo
16 property.
17+
18 """
19
20 def __init__(self, local_dir, lp_user=None, fetch_proto=None):
21+ """
22+ If fetch_proto is None, the default value from
23+ gitubuntu.__main__ will be used (top_level_defaults.proto).
24+ """
25 if local_dir is None:
26 self._local_dir = tempfile.mkdtemp()
27 else:
28@@ -465,6 +471,9 @@ class GitUbuntuRepository:
29 logging.error("Unable to determine Launchpad user")
30 sys.exit(1)
31
32+ if fetch_proto is None:
33+ fetch_proto = top_level_defaults.proto
34+
35 self._fetch_proto = fetch_proto
36
37 def create_orphan_branch(self, branch_name, msg):
38@@ -764,51 +773,65 @@ class GitUbuntuRepository:
39 # self.git_run(['config', 'url.%s.insteadof' % self.lp_user, 'lpme'])
40
41 def fetch_remote(self, remote_name, verbose=False):
42+ # Does not seem to be working with https
43+ # https://github.com/libgit2/pygit2/issues/573
44+ # https://github.com/libgit2/libgit2/issues/3786
45+ # self.raw_repo.remotes[remote_name].fetch()
46+ kwargs = {}
47+ kwargs['verbose_on_failure'] = True
48+ if verbose:
49+ # If we are redirecting stdout/stderr to the console, we
50+ # do not need to have run() also emit it
51+ kwargs['verbose_on_failure'] = False
52+ kwargs['stdout'] = None
53+ kwargs['stderr'] = None
54 try:
55- # Does not seem to be working with https
56- # https://github.com/libgit2/pygit2/issues/573
57- # https://github.com/libgit2/libgit2/issues/3786
58- # self.raw_repo.remotes[remote_name].fetch()
59- logging.debug('Fetching remote %s' % remote_name)
60- kwargs = {}
61- kwargs['verbose_on_failure'] = True
62- if verbose:
63- # If we are redirecting stdout/stderr to the console, we
64- # do not need to have run() also emit it
65- kwargs['verbose_on_failure'] = False
66- kwargs['stdout'] = None
67- kwargs['stderr'] = None
68- self.git_run(['fetch', remote_name], **kwargs)
69+ logging.debug("Fetching remote %s", remote_name)
70+ cp = self.git_run(
71+ args=['fetch', remote_name],
72+ env={'GIT_TERMINAL_PROMPT': '0',},
73+ **kwargs
74+ )
75 except CalledProcessError:
76 raise GitUbuntuRepositoryFetchError(
77- 'Unable to fetch remote %s' % remote_name
78+ "Unable to fetch remote %s" % remote_name
79 )
80
81 def fetch_base_remotes(self, verbose=False):
82 self.fetch_remote(remote_name='pkg', verbose=verbose)
83
84 def fetch_remote_refspecs(self, remote_name, refspecs, verbose=False):
85- try:
86- # Does not seem to be working with https
87- # https://github.com/libgit2/pygit2/issues/573
88- # https://github.com/libgit2/libgit2/issues/3786
89- # self.raw_repo.remotes[remote_name].fetch()
90- for refspec in refspecs:
91- logging.debug('Fetching refspec %s from remote %s' %
92- (refspec, remote_name))
93- kwargs = {}
94- kwargs['verbose_on_failure'] = True
95- if verbose:
96- # If we are redirecting stdout/stderr to the console, we
97- # do not need to have run() also emit it
98- kwargs['verbose_on_failure'] = False
99- kwargs['stdout'] = None
100- kwargs['stderr'] = None
101- self.git_run(['fetch', remote_name, refspec], **kwargs)
102- except CalledProcessError:
103- raise GitUbuntuRepositoryFetchError(
104- 'Unable to fetch %s from remote %s' % (refspecs, remote_name)
105- )
106+ # Does not seem to be working with https
107+ # https://github.com/libgit2/pygit2/issues/573
108+ # https://github.com/libgit2/libgit2/issues/3786
109+ # self.raw_repo.remotes[remote_name].fetch()
110+ for refspec in refspecs:
111+ kwargs = {}
112+ kwargs['verbose_on_failure'] = True
113+ if verbose:
114+ # If we are redirecting stdout/stderr to the console, we
115+ # do not need to have run() also emit it
116+ kwargs['verbose_on_failure'] = False
117+ kwargs['stdout'] = None
118+ kwargs['stderr'] = None
119+ try:
120+ logging.debug(
121+ "Fetching refspec %s from remote %s",
122+ refspec,
123+ remote_name,
124+ )
125+ self.git_run(
126+ args=['fetch', remote_name, refspec],
127+ env={'GIT_TERMINAL_PROMPT': '0',},
128+ **kwargs,
129+ )
130+ except CalledProcessError:
131+ raise GitUbuntuRepositoryFetchError(
132+ "Unable to fetch %s from remote %s" % (
133+ refspecs,
134+ remote_name,
135+ )
136+ )
137
138 def fetch_lpuser_remote(self, verbose=False):
139 if not self._fetch_proto:
140diff --git a/gitubuntu/versioning.py b/gitubuntu/versioning.py
141index c3187f5..3a5dc53 100644
142--- a/gitubuntu/versioning.py
143+++ b/gitubuntu/versioning.py
144@@ -27,7 +27,7 @@ __all__ = [
145 # see _decompose_version_string for explanation of members
146 _VersionComps = namedtuple(
147 "_VersionComps",
148- ["prefix_parts", "ubuntu_maj", "ubuntu_series", "ubuntu_min"]
149+ ["prefix_parts", "ubuntu_maj", "ubuntu_series", "ubuntu_other", "ubuntu_min"]
150 )
151
152 def _decompose_version_string(version_string):
153@@ -52,10 +52,19 @@ def _decompose_version_string(version_string):
154 "1.0.2ubuntu3.17.04.4", 17.04 is the Ubuntu series string. In both
155 "1.0-2ubuntu3.4" and "1.0-2", the Ubuntu series is not present.
156
157+ ubuntu_other is any non-series information as a string between the
158+ major and minor version numbers. For example, in the version strings
159+ "1.0-2ubuntu3.4" and "1.0-2ubuntu3.17.04.4", the other Ubuntu
160+ version string is not present. In both "1.0-2" and "1.0-2ubuntu3",
161+ the other Ubuntu version number is not present. In
162+ "1.2.2-0ubuntu13.1.23", "1" is the Ubuntu other version string.
163+
164 ubuntu_min is the "minor" Ubuntu version number as an integer, or None if
165 not present. For example, in the version strings "1.0-2ubuntu3.4" and
166 "1.0-2ubuntu3.17.04.4", 4 is the Ubuntu minor version number. In both
167- "1.0-2" and "1.0-2ubuntu3", the minor Ubuntu version number is not present.
168+ "1.0-2" and "1.0-2ubuntu3", the minor Ubuntu version number is not
169+ present. In "1.2.2-0ubuntu13.1.23", 23 is the Ubuntu minor version
170+ number.
171
172 For version strings not following these standard forms, the result is
173 undefined except where specific test cases exist for them.
174@@ -73,7 +82,7 @@ def _decompose_version_string(version_string):
175 )
176 elif 'build' in parts:
177 return _VersionComps._make(
178- [parts[:parts.index('build')], None, None, None]
179+ [parts[:parts.index('build')], None, None, None, None]
180 )
181 elif 'ubuntu' in parts:
182 ubuntu_idx = parts.index('ubuntu')
183@@ -85,6 +94,7 @@ def _decompose_version_string(version_string):
184 # nothing after "Xubuntu", treated as 1
185 ubuntu_maj = 1
186 ubuntu_series = None
187+ ubuntu_other = None
188 if len(suffix_parts) < 2:
189 ubuntu_min = None
190 else:
191@@ -95,15 +105,13 @@ def _decompose_version_string(version_string):
192 if len(suffix_parts[1:-1]) > 2:
193 ubuntu_series = ''.join(suffix_parts[2:-2])
194 if not re.match(r'\d\d\.\d\d', ubuntu_series):
195- raise ValueError("Not sure how to decompose %s: "
196- "series %s not in expected format" %
197- (version_string, ubuntu_series)
198- )
199+ ubuntu_series = None
200+ ubuntu_other = ''.join(suffix_parts[2:-2])
201 return _VersionComps._make(
202- [static_parts, ubuntu_maj, ubuntu_series, ubuntu_min]
203+ [static_parts, ubuntu_maj, ubuntu_series, ubuntu_other, ubuntu_min]
204 )
205 else:
206- return _VersionComps._make([parts, None, None, None])
207+ return _VersionComps._make([parts, None, None, None, None])
208
209
210 def _bump_version_object(old_version_object, bump_function):
211@@ -169,6 +177,8 @@ def _bump_sru_version_suffix_string(befores, series_string, afters,
212 bumped_parts = ['ubuntu', str(new_maj), '.']
213 if old_suffix_comps.ubuntu_series:
214 bumped_parts.extend([old_suffix_comps.ubuntu_series, '.'])
215+ elif old_suffix_comps.ubuntu_other:
216+ bumped_parts.extend([old_suffix_comps.ubuntu_other, '.'])
217 elif str(version) in [str(v) for v in befores + afters]:
218 bumped_parts.extend([series_string, '.'])
219 elif any(
220@@ -251,12 +261,13 @@ def version_compare(a, b):
221
222
223 @pytest.mark.parametrize('test_input, expected', [
224- ('2', _VersionComps._make([['2'], None, None, None])),
225- ('2ubuntu1', _VersionComps._make([['2'], 1, None, None])),
226- ('2ubuntu1.3', _VersionComps._make([['2'], 1, None, 3])),
227- ('2ubuntu0.16.04.3', _VersionComps._make([['2'], 0, '16.04', 3])),
228- ('2build1', _VersionComps._make([['2'], None, None, None])),
229- ('2build1.3', _VersionComps._make([['2'], None, None, None])),
230+ ('2', _VersionComps._make([['2'], None, None, None, None])),
231+ ('2ubuntu1', _VersionComps._make([['2'], 1, None, None, None])),
232+ ('2ubuntu1.3', _VersionComps._make([['2'], 1, None, None, 3])),
233+ ('2ubuntu0.16.04.3', _VersionComps._make([['2'], 0, '16.04', None, 3])),
234+ ('2build1', _VersionComps._make([['2'], None, None, None, None])),
235+ ('2build1.3', _VersionComps._make([['2'], None, None, None, None])),
236+ ('0ubuntu13.1.22', _VersionComps._make([['0'], 13, None, '1', 22])),
237 ])
238 def test_decompose_version_string(test_input, expected):
239 assert _decompose_version_string(test_input) == expected

Subscribers

People subscribed via source and target branches