Coverage for src/git_functions.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-16 12:50 +0000

1import os 

2import random 

3import string 

4import subprocess 

5 

6 

7def get_git_branch(): 

8 github_ref_name = os.getenv('GITHUB_HEAD_REF') 

9 if github_ref_name: 

10 return github_ref_name 

11 

12 try: 

13 branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip().decode() 

14 return branch 

15 except subprocess.CalledProcessError: 

16 return "unknown-branch" 

17 

18 

19def generate_short_hash(): 

20 return ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))