Skip to content

Commit

Permalink
#54 - fix issue with scm revision under Perforce
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhalimi committed Mar 18, 2022
1 parent a73b055 commit 8e0fe52
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pytest_monitor/sys_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ def collect_ci_info():


def determine_scm_revision():
for cmd in [r'git rev-parse HEAD', r'p4 changes -m1 \#have']:
for scm, cmd in (
('git', r'git rev-parse HEAD'),
('p4', r'p4 changes -m1 \#have')):
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
p_out, _ = p.communicate()
if p.returncode == 0:
return p_out.decode().split('\n')[0]
scm_ref = p_out.decode(errors='ignore').split('\n')[0]
if scm == 'p4':
scm_ref = scm_ref.split()[1]
return scm_ref
return ''


Expand Down

0 comments on commit 8e0fe52

Please sign in to comment.