106
105
return self._pr.html_url
107
def _branch_from_part(self, part):
108
return github_url_to_bzr_url(part.repo.html_url, part.ref)
110
def get_source_branch_url(self):
111
return self._branch_from_part(self._pr.head)
113
def get_target_branch_url(self):
114
return self._branch_from_part(self._pr.base)
108
116
def get_description(self):
109
117
return self._pr.body
205
215
def get_proposer(self, source_branch, target_branch):
206
216
return GitHubMergeProposalBuilder(self.gh, source_branch, target_branch)
208
def get_proposal(self, source_branch, target_branch):
218
def iter_proposals(self, source_branch, target_branch, status='open'):
209
219
(source_owner, source_repo_name, source_branch_name) = (
210
220
parse_github_url(source_branch))
211
221
(target_owner, target_repo_name, target_branch_name) = (
212
222
parse_github_url(target_branch))
213
target_repo = self.gh.get_repo("%s/%s" % (target_owner, target_repo_name))
214
for pull in target_repo.get_pulls(head=target_branch_name):
223
target_repo = self.gh.get_repo(
224
"%s/%s" % (target_owner, target_repo_name))
230
for pull in target_repo.get_pulls(
231
head=target_branch_name,
232
state=state[status]):
233
if (status == 'closed' and pull.merged or
234
status == 'merged' and not pull.merged):
215
236
if pull.head.ref != source_branch_name:
217
238
if (pull.head.repo.owner.login != source_owner or
218
239
pull.head.repo.name != source_repo_name):
220
return GitHubMergeProposal(pull)
221
raise NoMergeProposal()
241
yield GitHubMergeProposal(pull)
223
243
def hosts(self, branch):
236
256
raise UnsupportedHoster(branch)
260
def iter_instances(cls):
263
def iter_my_proposals(self, status='open'):
266
query.append('is:open')
267
elif status == 'closed':
268
# Note that we don't use is:closed here, since that also includes
269
# merged pull requests.
270
query.append('is:unmerged')
271
elif status == 'merged':
272
query.append('is:merged')
273
query.append('author:%s' % self.gh.get_user().login)
274
for issue in self.gh.search_issues(query=' '.join(query)):
275
yield GitHubMergeProposal(issue.as_pull_request())
240
278
class GitHubMergeProposalBuilder(MergeProposalBuilder):