Skip to content

Commit a3b5362

Browse files
committed
9pm.py: refactor printing of project info
And add a warning if there's no .git dir in PROJECT_ROOT. Signed-off-by: Richard Alpe <[email protected]>
1 parent 27c2de4 commit a3b5362

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

9pm.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ def setup_env(args):
669669

670670
def run_git_cmd(path, command):
671671
if not os.path.isdir(os.path.join(path, '.git')):
672+
vcprint(pcolor.orange, f"warning, no .git dir in path ({path})")
672673
return ""
673674

674675
try:
@@ -680,6 +681,20 @@ def run_git_cmd(path, command):
680681
except (FileNotFoundError, subprocess.CalledProcessError):
681682
return ""
682683

684+
def pr_proj_info(proj):
685+
str = f"\nTesting"
686+
687+
if 'PROJECT-NAME' in proj:
688+
str += f" {proj['PROJECT-NAME']}"
689+
690+
if 'PROJECT-ROOT' in proj:
691+
git_sha = run_git_cmd(os.path.join(ROOT_PATH, proj['PROJECT-ROOT']), ['rev-parse', 'HEAD'])[:12]
692+
693+
if git_sha:
694+
str += f" ({git_sha})"
695+
696+
cprint(pcolor.yellow, str)
697+
683698
def main():
684699
global DATABASE
685700
global SCRATCHDIR
@@ -711,11 +726,7 @@ def main():
711726
vcprint(pcolor.faint, f"Created databasefile: {db.name}")
712727
DATABASE = db.name
713728

714-
if 'PROJECT-NAME' in proj:
715-
str = f"\nTesting {proj['PROJECT-NAME']}"
716-
if 'PROJECT-ROOT' in proj:
717-
str += f" ({run_git_cmd(os.path.join(ROOT_PATH, proj['PROJECT-ROOT']), ['rev-parse', 'HEAD'])[:12]})"
718-
cprint(pcolor.yellow, str)
729+
pr_proj_info(proj)
719730

720731
cmdl = {'name': 'command-line', 'suite': []}
721732
for filename in args.suites:

0 commit comments

Comments
 (0)