summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--b4/ty.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/b4/ty.py b/b4/ty.py
index a2f3d5f..02898b0 100644
--- a/b4/ty.py
+++ b/b4/ty.py
@@ -589,15 +589,33 @@ def get_branch_info(gitdir, branch):
remotecfg = b4.get_config_from_git('branch\\.%s\\.*' % branch)
if remotecfg is None or 'remote' not in remotecfg:
- # Not found any matching remotes
- return BRANCH_INFO
+ # Did not find a matching branch entry, so look at remotes
+ gitargs = ['remote', 'show']
+ lines = b4.git_get_command_lines(gitdir, gitargs)
+ if not len(lines):
+ # No remotes? Hmm...
+ return BRANCH_INFO
+
+ remote = None
+ for entry in lines:
+ if branch.find(f'{entry}/') == 0:
+ remote = entry
+ break
- BRANCH_INFO['remote'] = remotecfg['remote']
- if 'merge' in remotecfg:
- BRANCH_INFO['branch'] = re.sub(r'^refs/heads/', '', remotecfg['merge'])
+ if remote is None:
+ # Not found any matching remotes
+ return BRANCH_INFO
+
+ BRANCH_INFO['remote'] = remote
+ BRANCH_INFO['branch'] = branch.replace(f'{remote}/', '')
+
+ else:
+ BRANCH_INFO['remote'] = remotecfg['remote']
+ if 'merge' in remotecfg:
+ BRANCH_INFO['branch'] = re.sub(r'^refs/heads/', '', remotecfg['merge'])
# Grab template overrides
- remotecfg = b4.get_config_from_git('remote\\.%s\\..*' % remotecfg['remote'])
+ remotecfg = b4.get_config_from_git('remote\\.%s\\..*' % BRANCH_INFO['remote'])
BRANCH_INFO.update(remotecfg)
return BRANCH_INFO