From 5e25a8aeb2a8e5a2b9959fa876cdc99d2e1e3f8f Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Wed, 9 Jul 2014 21:28:26 -0400 Subject: [PATCH] Use git API to find base branch name for PRs when looking for common branch names in extra deps --- runbot/runbot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runbot/runbot.py b/runbot/runbot.py index ea26823a..b4b58de0 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -533,6 +533,11 @@ class runbot_build(osv.osv): for build in self.browse(cr, uid, ids, context=context): branch, repo = build.branch_id, build.repo_id name = branch.branch_name + # Use github API to find name of branch on which the PR is made + if repo.token and name.startswith('refs/pull/'): + pull_number = name[len('refs/pull/'):] + pr = repo.github('/repos/:owner/:repo/pulls/%s' % pull_number) + name = 'refs/heads/' + pr['base']['ref'] # Find common branch names between repo and target repo branch_ids = branch_pool.search(cr, uid, [('repo_id.id', '=', repo.id)]) target_ids = branch_pool.search(cr, uid, [('repo_id.id', '=', target_repo_id)])