1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

no install of git hook if checked out as submodule

This commit is contained in:
Rene Schallner 2023-01-19 12:41:25 +01:00
parent 218b556d30
commit 3af5b7b939

View file

@ -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,