From 34f5c4ef026b9b9478a7b5b10f990fb6502e550d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 24 Aug 2021 20:58:23 -0700 Subject: [PATCH] git: Fix git_repository_name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- zulip/integrations/git/post-receive | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/zulip/integrations/git/post-receive b/zulip/integrations/git/post-receive index be5522a..a077223 100755 --- a/zulip/integrations/git/post-receive +++ b/zulip/integrations/git/post-receive @@ -33,11 +33,10 @@ client = zulip.Client( def git_repository_name() -> str: - output = subprocess.check_output(["git", "rev-parse", "--is-bare-repository"]) - if output.strip() == "true": - return os.path.basename(os.getcwd())[: -len(".git")] - else: - return os.path.basename(os.path.dirname(os.getcwd())) + path, name = os.path.split(os.getcwd()) + if name == ".git": + name = os.path.basename(path) + return name[: -len(".git")] if name.endswith(".git") else name def git_commit_range(oldrev: str, newrev: str) -> str: