1
0

pkgs/git-show-link: Display error message when not executed in a git repo

This commit is contained in:
2025-05-23 14:28:03 +02:00
parent b93dc9f16b
commit 4e56adef58

@ -29,6 +29,11 @@ class FormatArgs:
commit: str = None
branch: str = None
def is_git_repo():
s = subprocess.run(["git", "rev-parse"], capture_output=True, text=True)
return s.returncode == 0
def get_remote_branch():
s = subprocess.run(["git", "status", "--porcelain", "-uno", "-b", "--no-ahead-behind"], capture_output=True, text=True)
@ -71,6 +76,11 @@ def main():
args = parser.parse_args()
if not is_git_repo():
print("Not a git repo")
exit(1)
r = get_remote_branch()
remote_url = get_remote_url(r["remote"])