From df1776a39a8df7e140ae3e62efe4c82895a1e91c Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 30 Mar 2020 12:15:07 -0400 Subject: PR: fix when gitdir is specified via -g Fix some leftover bugs from prototyping stage when we were always assuming to run from a checkout. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 2 ++ b4/pr.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 0f0b76c..b4ce2d4 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1267,6 +1267,8 @@ def gpg_run_command(args, stdin=None, logstderr=False): def git_run_command(gitdir, args, stdin=None, logstderr=False): cmdargs = ['git', '--no-pager'] if gitdir: + if os.path.isdir(os.path.join(gitdir, '.git')): + gitdir = os.path.join(gitdir, '.git') cmdargs += ['--git-dir', gitdir] cmdargs += args diff --git a/b4/pr.py b/b4/pr.py index 24fbf64..55261f1 100644 --- a/b4/pr.py +++ b/b4/pr.py @@ -133,7 +133,7 @@ def fetch_remote(gitdir, lmsg, branch=None): # Fetch it now logger.info(' Fetching %s %s', lmsg.pr_repo, lmsg.pr_ref) gitargs = ['fetch', lmsg.pr_repo, lmsg.pr_ref] - ecode, out = b4.git_run_command(None, gitargs, logstderr=True) + ecode, out = b4.git_run_command(gitdir, gitargs, logstderr=True) if ecode > 0: logger.critical('ERROR: Could not fetch remote:') logger.critical(out) @@ -143,7 +143,7 @@ def fetch_remote(gitdir, lmsg, branch=None): if branch: gitargs = ['checkout', '-b', branch, 'FETCH_HEAD'] logger.info('Fetched into branch %s', branch) - ecode, out = b4.git_run_command(None, gitargs) + ecode, out = b4.git_run_command(gitdir, gitargs) if ecode > 0: logger.critical('ERROR: Failed to create branch') logger.critical(out) @@ -156,7 +156,9 @@ def fetch_remote(gitdir, lmsg, branch=None): def explode(gitdir, lmsg, savefile): # We always fetch into FETCH_HEAD when exploding - fetch_remote(gitdir, lmsg) + ecode = fetch_remote(gitdir, lmsg) + if ecode > 0: + sys.exit(ecode) logger.info('Generating patches starting from the base-commit') reroll = None if lmsg.revision > 1: -- cgit v1.2.3