From 444f0564fbe0d25f5cad52cb6899b2c2ad9f1cf7 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 22 Apr 2020 18:35:41 -0400 Subject: Properly deal with merge to non-current branch When running rev-list, be mindful of which branch we need to operate on, otherwise it always runs on the current branch. Reported-by: Mark Brown Signed-off-by: Konstantin Ryabitsev --- b4/ty.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/b4/ty.py b/b4/ty.py index 008da09..8c61cd2 100644 --- a/b4/ty.py +++ b/b4/ty.py @@ -51,9 +51,11 @@ MY_COMMITS = None BRANCH_INFO = None -def git_get_merge_id(gitdir, commit_id): +def git_get_merge_id(gitdir, commit_id, branch=None): # get merge commit id args = ['rev-list', '%s..' % commit_id, '--ancestry-path'] + if branch is not None: + args += [branch] lines = b4.git_get_command_lines(gitdir, args) if not len(lines): return None @@ -117,7 +119,7 @@ def auto_locate_pr(gitdir, jsondata, branch): return None # Get the merge commit - merge_commit_id = git_get_merge_id(gitdir, pr_commit_id) + merge_commit_id = git_get_merge_id(gitdir, pr_commit_id, branch) if not merge_commit_id: logger.debug('Could not get a merge commit-id for %s', pr_commit_id) return None -- cgit v1.2.3