Skip to content

Commit ba12cc8

Browse files
committed
Fix annoying warnings when running in a container
This is a follow-up to 07f28a4 which added support for figuring out the GIT revision when 9pm is a submodule in another proejct. However, that project in turn may be a git worktree, where the actual .git directory is elsewhere, and when said project is running its tests from a Docker container, things get worse. It is very likely that the actual .git directory is unreachable from within the container. This patch hides the following annoying warnings: warning, git command failed (Command '['git', '--git-dir', '/home/jocke/src/x-misc/test/9pm/../../../infix/.git/worktrees/x-misc/modules/9pm', 'rev-parse', 'HEAD']' returned non-zero exit status 128.) 9PM - Simplicity is the ultimate sophistication warning, git command failed (Command '['git', '--git-dir', '/home/jocke/src/infix/.git/worktrees/x-misc', 'rev-parse', 'HEAD']' returned non-zero exit status 128.) Testing Infix Running suite 0001 all.yaml Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 6b286b9 commit ba12cc8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

9pm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,9 @@ def run_git_cmd(path, command):
809809
line = f.read().strip()
810810
if line.startswith('gitdir: '):
811811
gitdir = os.path.join(path, line[8:])
812+
# Sanity check the path is actually reachable, we may run in a container
813+
if not os.path.exists(gitdir):
814+
return ""
812815
else:
813816
vcprint(pcolor.orange, f"warning, invalid .git file format ({path})")
814817
return ""

0 commit comments

Comments
 (0)