Coverage for pyguymer3/git_remote.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_remote( 

5 cwd, 

6 /, 

7 *, 

8 gitPath = None, 

9 name = "origin", 

10 timeout = 60.0, 

11): 

12 # Import standard modules ... 

13 import shutil 

14 import subprocess 

15 

16 # ************************************************************************** 

17 

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

19 if gitPath is None: 

20 gitPath = shutil.which("git") 

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

22 

23 # Find the remote URL of the repository ... 

24 resp = subprocess.run( 

25 [ 

26 gitPath, 

27 "remote", 

28 "get-url", 

29 name, 

30 ], 

31 check = True, 

32 cwd = cwd, 

33 encoding = "utf-8", 

34 stderr = subprocess.STDOUT, 

35 stdout = subprocess.PIPE, 

36 timeout = timeout, 

37 ) 

38 

39 # Return answer ... 

40 return resp.stdout.strip()