pkgs/git-show-link: Display error message when not executed in a git repo
This commit is contained in:
@ -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"])
|
||||
|
Reference in New Issue
Block a user