From 0606eb58465636d39bdaeadcd59672910994d008 Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Sat, 11 Mar 2017 17:53:35 -0500 Subject: [PATCH] Fix parsing of `git remote show origin -n` in get_project_name --- abf/console/misc.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/abf/console/misc.py b/abf/console/misc.py index b61a5f0..ba084ce 100644 --- a/abf/console/misc.py +++ b/abf/console/misc.py @@ -45,11 +45,10 @@ def get_project_name(path=None): e["LC_ALL"] = "C" output, ret_code = execute_command(['git', 'remote', 'show', 'origin', '-n'], cwd=path, env=e) - for line in output.split('\n'): - if line.startswith(' Fetch URL:') and 'abf' in line: - project_name = line.split('/')[-1][:-4] - owner_name = line.split('/')[-2] - return (owner_name, project_name) + m = re.compile("^.*Fetch URL:\s+.*abf.*:(.+)/([^/]+)[.]git$",re.MULTILINE).search(output) + if m: + owner_name, project_name = m.groups() + return (owner_name, project_name) return (None, None) except ReturnCodeNotZero: return (None, None)