From 3af5b7b9397de6b6f14d4f96bc3d36efded4225b Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Thu, 19 Jan 2023 12:41:25 +0100 Subject: [PATCH] no install of git hook if checked out as submodule --- build.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.zig b/build.zig index a02f249..1b9b7bf 100644 --- a/build.zig +++ b/build.zig @@ -142,6 +142,16 @@ fn ensureGit(allocator: std.mem.Allocator) void { } pub fn ensureGitHook(allocator: std.mem.Allocator) void { + // only check if we ourselves are not part of a submodule + var cwd = std.fs.cwd().openDir(sdkPath("/"), .{}) catch return; + defer cwd.close(); + const dotgit = cwd.statFile(".git") catch return; + if (dotgit.kind == .File) { + // we are checked out as a submodule. No point in trying to install + // a hook + return; + } + var child = std.ChildProcess.init( &.{ "cp", "precommit-hook.sh", ".git/hooks/pre-commit" }, allocator,