Merge lp:~jelmer/brz/fix-github into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix-github
Merge into: lp:brz/3.1
Diff against target: 96 lines (+21/-8)
3 files modified
breezy/plugins/github/hoster.py (+12/-6)
breezy/plugins/gitlab/hoster.py (+1/-1)
breezy/plugins/launchpad/hoster.py (+8/-1)
To merge this branch: bzr merge lp:~jelmer/brz/fix-github
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+387253@code.launchpad.net

Commit message

Fix name error, lazily load user in GitHub.

Description of the change

Fix name error, lazily load user in GitHub.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/plugins/github/hoster.py'
2--- breezy/plugins/github/hoster.py 2020-06-18 03:08:00 +0000
3+++ breezy/plugins/github/hoster.py 2020-07-11 22:20:20 +0000
4@@ -388,7 +388,7 @@
5 return self._list_paged(path, {'q': query}, per_page=DEFAULT_PER_PAGE)
6
7 def _create_fork(self, path, owner=None):
8- if owner and owner != self._current_user['login']:
9+ if owner and owner != self.current_user['login']:
10 path += '?organization=%s' % owner
11 response = self._api_request('POST', path)
12 if response.status != 202:
13@@ -402,7 +402,13 @@
14 def __init__(self, transport):
15 self._token = retrieve_github_token('https', GITHUB_HOST)
16 self.transport = transport
17- self._current_user = self._get_user()
18+ self._current_user = None
19+
20+ @property
21+ def current_user(self):
22+ if self._current_user is None:
23+ self._current_user = self._get_user()
24+ return self._current_user
25
26 def publish_derived(self, local_branch, base_branch, name, project=None,
27 owner=None, revision_id=None, overwrite=False,
28@@ -410,7 +416,7 @@
29 base_owner, base_project, base_branch_name = parse_github_branch_url(base_branch)
30 base_repo = self._get_repo(base_owner, base_project)
31 if owner is None:
32- owner = self._current_user['login']
33+ owner = self.current_user['login']
34 if project is None:
35 project = base_repo['name']
36 try:
37@@ -446,7 +452,7 @@
38 base_owner, base_project, base_branch_name = parse_github_branch_url(base_branch)
39 base_repo = self._get_repo(base_owner, base_project)
40 if owner is None:
41- owner = self._current_user['login']
42+ owner = self.current_user['login']
43 if project is None:
44 project = base_repo['name']
45 try:
46@@ -521,7 +527,7 @@
47 query.append('is:closed')
48 elif status == 'merged':
49 query.append('is:merged')
50- query.append('author:%s' % self._current_user['login'])
51+ query.append('author:%s' % self.current_user['login'])
52 for issue in self._search_issues(query=' '.join(query)):
53 url = issue['pull_request']['url']
54 response = self._api_request('GET', url)
55@@ -535,7 +541,7 @@
56 def iter_my_forks(self):
57 response = self._api_request('GET', '/user/repos')
58 if response.status != 200:
59- raise InvalidHttpResponse(url, response.text)
60+ raise InvalidHttpResponse(self.transport.user_url, response.text)
61 for project in json.loads(response.text):
62 if not project['fork']:
63 continue
64
65=== modified file 'breezy/plugins/gitlab/hoster.py'
66--- breezy/plugins/gitlab/hoster.py 2020-06-25 00:06:34 +0000
67+++ breezy/plugins/gitlab/hoster.py 2020-07-11 22:20:20 +0000
68@@ -558,7 +558,7 @@
69 raise GitLabLoginMissing()
70 else:
71 raise GitlabLoginError(response.text)
72- raise UnsupportedHoster(url)
73+ raise UnsupportedHoster(self.base_url)
74
75 @classmethod
76 def probe_from_url(cls, url, possible_transports=None):
77
78=== modified file 'breezy/plugins/launchpad/hoster.py'
79--- breezy/plugins/launchpad/hoster.py 2020-06-22 10:25:04 +0000
80+++ breezy/plugins/launchpad/hoster.py 2020-07-11 22:20:20 +0000
81@@ -230,7 +230,14 @@
82 lp_base_url = uris.STAGING_SERVICE_ROOT
83 else:
84 lp_base_url = uris.LPNET_SERVICE_ROOT
85- self.launchpad = lp_api.connect_launchpad(lp_base_url, version='devel')
86+ self._api_base_url = lp_base_url
87+ self._launchpad = None
88+
89+ @property
90+ def launchpad(self):
91+ if self._launchpad is None:
92+ self._launchpad = lp_api.connect_launchpad(self._api_base_url, version='devel')
93+ return self._launchpad
94
95 @property
96 def base_url(self):

Subscribers

People subscribed via source and target branches