diff --git a/pkgs/git-show-link/git-show-link.py b/pkgs/git-show-link/git-show-link.py index 63647d0..aeb8c94 100755 --- a/pkgs/git-show-link/git-show-link.py +++ b/pkgs/git-show-link/git-show-link.py @@ -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"])