Merge ~racb/git-ubuntu:fix-remote-add-changelog-notes into git-ubuntu:master

Proposed by Robie Basak
Status: Merged
Merged at revision: 9804f96758994b20f4cd1e5010c0390d768bef49
Proposed branch: ~racb/git-ubuntu:fix-remote-add-changelog-notes
Merge into: git-ubuntu:master
Diff against target: 133 lines (+65/-13)
1 file modified
gitubuntu/git_repository.py (+65/-13)
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+383513@code.launchpad.net

Commit message

Make Jenkins happy

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:30569f8934bd4b2dab2124889f64bdf626e2804b
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/510/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    IN_PROGRESS: Declarative: Post Actions

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

review: Approve (continuous-integration)
Revision history for this message
Bryce Harrington (bryce) wrote :

Looks good.

I might name the 'changelog_notes' parameter to 'has_changelog_notes' to better communicate that it's a bool rather than e.g. a list of notes or something. But this is internal and well documented so fine if you'd rather keep it as is. Either way, no need for another review round trip.

Otherwise, is a very straightforward fix, and very nice to see the additional code docs.

review: Approve
Revision history for this message
Robie Basak (racb) wrote :

Thank you for the review. I agree with the "has_changelog_notes" improvement, but I will avoid that for now to save another manual test cycle (as we have no automatic tests).

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 9bf5a8f..1ea6c6d 100644
3--- a/gitubuntu/git_repository.py
4+++ b/gitubuntu/git_repository.py
5@@ -1307,8 +1307,23 @@ class GitUbuntuRepository:
6 self,
7 remote_name,
8 fetch_url,
9- push_url=None
10+ push_url=None,
11+ changelog_notes=False,
12 ):
13+ """Add a remote by URL
14+
15+ If a remote with the given name doesn't exist, then create it.
16+ Otherwise, do nothing.
17+
18+ :param str remote_name: the name of the remote to create
19+ :param str fetch_url: the fetch URL for the remote
20+ :param str push_url: the push URL for the remote. If None, then a
21+ specific push URL will not be set.
22+ :param bool changelog_notes: if True, then a fetch refspec will be
23+ added to fetch changelog notes. This only makes sense for an
24+ official importer remote such as 'pkg'.
25+ :returns: None
26+ """
27 if not self._fetch_proto:
28 raise Exception('Cannot fetch using an object without a protocol')
29
30@@ -1325,13 +1340,14 @@ class GitUbuntuRepository:
31 remote_name,
32 '+refs/tags/*:refs/tags/%s/*' % remote_name,
33 )
34- # The changelog notes are kept at refs/notes/commits on
35- # Launchpad due to LP: #1871838 even though our standard place for
36- # them is refs/notes/changelog.
37- self.raw_repo.remotes.add_fetch(
38- remote_name,
39- '+refs/notes/commits:refs/notes/changelog',
40- )
41+ if changelog_notes:
42+ # The changelog notes are kept at refs/notes/commits on
43+ # Launchpad due to LP: #1871838 even though our standard place
44+ # for them is refs/notes/changelog.
45+ self.raw_repo.remotes.add_fetch(
46+ remote_name,
47+ '+refs/notes/commits:refs/notes/changelog',
48+ )
49 if push_url:
50 self.raw_repo.remotes.set_push_url(
51 remote_name,
52@@ -1345,7 +1361,25 @@ class GitUbuntuRepository:
53 ]
54 )
55
56- def _add_remote(self, remote_name, remote_url):
57+ def _add_remote(self, remote_name, remote_url, changelog_notes=False):
58+ """Add a remote by URL location
59+
60+ URL location means the part of the URL after the proto:// prefix. The
61+ protocol to be used will be determined by what was specified by the
62+ fetch_proto at class instance construction time. Separate fetch and
63+ push URL protocols will be automatically determined.
64+
65+ If a remote with the given name doesn't exist, then create it.
66+ Otherwise, do nothing.
67+
68+ :param str remote_name: the name of the remote to create
69+ :param str remote_url: the URL for the remote but with the proto://
70+ prefix missing.
71+ :param bool changelog_notes: if True, then a fetch refspec will be
72+ added to fetch changelog notes. This only makes sense for an
73+ official importer remote such as 'pkg'.
74+ :returns: None
75+ """
76 if not self._fetch_proto:
77 raise Exception('Cannot fetch using an object without a protocol')
78 if not self._lp_user:
79@@ -1353,9 +1387,20 @@ class GitUbuntuRepository:
80 fetch_url = '%s://%s' % (self._fetch_proto, remote_url)
81 push_url = 'ssh://%s@%s' % (self.lp_user, remote_url)
82
83- self._add_remote_by_fetch_url(remote_name, fetch_url, push_url)
84+ self._add_remote_by_fetch_url(
85+ remote_name=remote_name,
86+ fetch_url=fetch_url,
87+ push_url=push_url,
88+ changelog_notes=changelog_notes,
89+ )
90
91- def add_remote(self, pkgname, repo_owner, remote_name):
92+ def add_remote(
93+ self,
94+ pkgname,
95+ repo_owner,
96+ remote_name,
97+ changelog_notes=False,
98+ ):
99 """Add a remote to the repository configuration
100 :param str pkgname: the name of the source package reflected by this
101 repository.
102@@ -1364,6 +1409,9 @@ class GitUbuntuRepository:
103 If None, the default repository for the source package will be
104 used.
105 :param str remote_name: the name of the remote to add.
106+ :param bool changelog_notes: if True, then a fetch refspec will be
107+ added to fetch changelog notes. This only makes sense for an
108+ official importer remote such as 'pkg'.
109 :returns: None
110 """
111 if not self._fetch_proto:
112@@ -1374,7 +1422,11 @@ class GitUbuntuRepository:
113 else:
114 remote_url = ('git.launchpad.net/ubuntu/+source/%s' % pkgname)
115
116- self._add_remote(remote_name, remote_url)
117+ self._add_remote(
118+ remote_name=remote_name,
119+ remote_url=remote_url,
120+ changelog_notes=changelog_notes,
121+ )
122
123 def add_remote_by_url(self, remote_name, fetch_url):
124 if not self._fetch_proto:
125@@ -1393,7 +1445,7 @@ class GitUbuntuRepository:
126 used.
127 :returns: None
128 """
129- self.add_remote(pkgname, repo_owner, 'pkg')
130+ self.add_remote(pkgname, repo_owner, 'pkg', changelog_notes=True)
131
132 def add_lpuser_remote(self, pkgname):
133 if not self._fetch_proto:

Subscribers

People subscribed via source and target branches