Coverage for pyguymer3/git_files.py: 12%

8 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def git_files( 

5 cwd, 

6 /, 

7 *, 

8 gitPath = None, 

9 timeout = 60.0, 

10): 

11 # Import standard modules ... 

12 import shutil 

13 import subprocess 

14 

15 # ************************************************************************** 

16 

17 # Try to find the paths if the user did not provide them ... 

18 if gitPath is None: 

19 gitPath = shutil.which("git") 

20 assert gitPath is not None, "\"git\" is not installed" 

21 

22 # Find the full paths of all of the files in the repository ... 

23 resp = subprocess.run( 

24 [ 

25 gitPath, 

26 "ls-tree", 

27 "--full-tree", 

28 "-r", 

29 "--name-only", 

30 "HEAD", 

31 ], 

32 check = True, 

33 cwd = cwd, 

34 encoding = "utf-8", 

35 stderr = subprocess.STDOUT, 

36 stdout = subprocess.PIPE, 

37 timeout = timeout, 

38 ) 

39 

40 # Return answer ... 

41 return sorted(resp.stdout.strip().splitlines())