Coverage for /usr/local/lib/python3.12/site-packages/prefect/utilities/_git.py: 29%
17 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 11:21 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 11:21 +0000
1from __future__ import annotations 1a
3import subprocess 1a
4import sys 1a
7def get_git_remote_origin_url() -> str | None: 1a
8 """
9 Returns the git remote origin URL for the current directory.
10 """
11 try:
12 origin_url = subprocess.check_output(
13 ["git", "config", "--get", "remote.origin.url"],
14 shell=sys.platform == "win32",
15 stderr=subprocess.DEVNULL,
16 )
17 origin_url = origin_url.decode().strip()
18 except subprocess.CalledProcessError:
19 return None
21 return origin_url
24def get_git_branch() -> str | None: 1a
25 """
26 Returns the git branch for the current directory.
27 """
28 try:
29 branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
30 branch = branch.decode().strip()
31 except subprocess.CalledProcessError:
32 return None
34 return branch