mirror of
https://github.com/zigzap/zap.git
synced 2025-10-21 07:34:08 +00:00
no install of git hook if checked out as submodule
This commit is contained in:
parent
218b556d30
commit
3af5b7b939
1 changed files with 10 additions and 0 deletions
10
build.zig
10
build.zig
|
@ -142,6 +142,16 @@ fn ensureGit(allocator: std.mem.Allocator) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensureGitHook(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(
|
var child = std.ChildProcess.init(
|
||||||
&.{ "cp", "precommit-hook.sh", ".git/hooks/pre-commit" },
|
&.{ "cp", "precommit-hook.sh", ".git/hooks/pre-commit" },
|
||||||
allocator,
|
allocator,
|
||||||
|
|
Loading…
Add table
Reference in a new issue