diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-30 12:15:07 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-30 12:15:07 -0400 |
commit | df1776a39a8df7e140ae3e62efe4c82895a1e91c (patch) | |
tree | 93f6e546f80f1e54227d28d2f1c178d2591d3cb4 | |
parent | e110a35e7ea0a1c2bb3c350487a9fe34984592bf (diff) | |
download | b4-df1776a39a8df7e140ae3e62efe4c82895a1e91c.tar.gz |
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 <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 2 | ||||
-rw-r--r-- | 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 @@ -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: |