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>
This commit is contained in:
parent
d32d442c44
commit
34f5c4ef02
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue