Skip to content

Commit 34f5c4e

Browse files
committed
git: Fix git_repository_name.
Without universal_newlines=True or text=True, subprocess.check_output returns bytes, not str, so it makes no sense to compare its return to "true". But upstream Git’s behavior only depends on the filename, not whether the repository is bare; emulate this more closely. Signed-off-by: Anders Kaseorg <anders@zulip.com>
1 parent d32d442 commit 34f5c4e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

zulip/integrations/git/post-receive

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ client = zulip.Client(
3333

3434

3535
def git_repository_name() -> str:
36-
output = subprocess.check_output(["git", "rev-parse", "--is-bare-repository"])
37-
if output.strip() == "true":
38-
return os.path.basename(os.getcwd())[: -len(".git")]
39-
else:
40-
return os.path.basename(os.path.dirname(os.getcwd()))
36+
path, name = os.path.split(os.getcwd())
37+
if name == ".git":
38+
name = os.path.basename(path)
39+
return name[: -len(".git")] if name.endswith(".git") else name
4140

4241

4342
def git_commit_range(oldrev: str, newrev: str) -> str:

0 commit comments

Comments
 (0)