diff --git a/deps.zig b/deps.zig index c8d17080f29d0432cc951867b541f7627f365882..d5076899cfbed102a075cbcf3390a5c339d8012b 100644 --- a/deps.zig +++ b/deps.zig @@ -61,12 +61,14 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "c3e439f86b0484e4428f38c4d8b07b7b5ae1634b").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step); + step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-git", "103f4e419c35b88f802bb8234ece1c0a9aa40c03").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "9e1d873db79e9ffa6ae6e06bd372428c9be85d97").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e548b0bcc7b6f34f636c0b6b905928d31254c54d").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "ba546bbf2e8438c9b2325f36f392c9d95b432e8e").step); + step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "ad868b45cfd445aa4d3f53cf8dda4b62b73efb54").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step); step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "a7f03a1e652abe8c89b376d090cec50acb0d2a1a").step); step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "0ad514dcfb7525e32ae349b9acc0a53976f3a9fa").step); @@ -234,6 +236,18 @@ pub const package_data = struct { .entry = "/git/github.com/nektro/zig-time/ba546bbf2e8438c9b2325f36f392c9d95b432e8e/time.zig", .deps = &[_]*Package{ &_f7dubzb7cyqe }, }; + pub var _ede2wygpe1iy = Package{ + .store = "/git/github.com/nektro/zig-tracer/ad868b45cfd445aa4d3f53cf8dda4b62b73efb54", + .name = "tracer", + .entry = "/git/github.com/nektro/zig-tracer/ad868b45cfd445aa4d3f53cf8dda4b62b73efb54/src/mod.zig", + .deps = &[_]*Package{ &_f7dubzb7cyqe }, + }; + pub var _0k64oe2nuzvj = Package{ + .store = "/git/github.com/nektro/zig-git/103f4e419c35b88f802bb8234ece1c0a9aa40c03", + .name = "git", + .entry = "/git/github.com/nektro/zig-git/103f4e419c35b88f802bb8234ece1c0a9aa40c03/git.zig", + .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy }, + }; pub var _g982zq6e8wsv = Package{ .store = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b", .name = "yaml", @@ -259,7 +273,7 @@ pub const package_data = struct { pub var _89ujp8gq842x = Package{ .name = "zigmod", .entry = "/../..//src/lib.zig", - .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe }, + .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj }, }; pub var _root = Package{ }; diff --git a/licenses.txt b/licenses.txt index 7da938d7c008343d4367a7bf2559fabc391b1b73..edfd4f54cc3275632415ee8f3c6235704fb3c035 100644 --- a/licenses.txt +++ b/licenses.txt @@ -8,12 +8,14 @@ MIT: - git https://github.com/nektro/zig-ansi - git https://github.com/nektro/zig-detect-license - git https://github.com/nektro/zig-extras +- git https://github.com/nektro/zig-git - git https://github.com/nektro/zig-inquirer - git https://github.com/nektro/zig-leven - git https://github.com/nektro/zig-licenses - git https://github.com/nektro/zig-licenses-text - git https://github.com/nektro/zig-range - git https://github.com/nektro/zig-time +- git https://github.com/nektro/zig-tracer - git https://github.com/nektro/zig-yaml - git https://github.com/truemedian/hzzp - git https://github.com/ziglibs/known-folders diff --git a/src/util/funcs.zig b/src/util/funcs.zig index e35a7c9db2a14fb5d3942155b7369661f2ac19b0..27f2751c5f8bbcc7ff9a7f1c32e469db0dcd1582 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -2,6 +2,7 @@ const std = @import("std"); const string = []const u8; const gpa = std.heap.c_allocator; const extras = @import("extras"); +const git = @import("git"); const u = @import("index.zig"); @@ -147,11 +148,10 @@ pub fn do_hash(comptime algo: type, data: string) ![algo.digest_length * 2]u8 { /// Returns the result of running `git rev-parse HEAD` pub fn git_rev_HEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !string { - const dirg = try dir.openDir(".git", .{}); - const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", 50), "\n"); - if (!std.mem.startsWith(u8, h, "ref:")) return h; - const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], 50), "\n"); - return r; + var dirg = try dir.openDir(".git", .{}); + defer dirg.close(); + const commitid = try git.getHEAD(alloc, dirg); + return if (commitid) |_| commitid.?.id else error.NotAGitRepo; } pub fn slice(comptime T: type, input: []const T, from: usize, to: usize) []const T { diff --git a/zig.mod b/zig.mod index 55c824d6dbbe86711ac6a30dd7be031271195fcc..aabb8a3640f0073dac4e10fdbe59316625aead45 100644 --- a/zig.mod +++ b/zig.mod @@ -15,6 +15,7 @@ dependencies: - src: git https://github.com/nektro/arqv-ini - src: git https://github.com/nektro/zig-time - src: git https://github.com/nektro/zig-extras + - src: git https://github.com/nektro/zig-git root_dependencies: - src: git https://github.com/marlersoft/zigwin32 diff --git a/zigmod.lock b/zigmod.lock index 535436c9e528b3e348f833668cadfcb58b97e206..1adab10d27126af2394d13524ef373db8764528c 100644 --- a/zigmod.lock +++ b/zigmod.lock @@ -6,12 +6,14 @@ git https://github.com/nektro/zfetch commit-863be236188e5f24d16554f9dcd7df96dd25 git https://github.com/nektro/zig-ansi commit-c3e439f86b0484e4428f38c4d8b07b7b5ae1634b git https://github.com/nektro/zig-detect-license commit-3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd git https://github.com/nektro/zig-extras commit-74f0ddb0a4dfa7921739b88cc381951a6b6e73ce +git https://github.com/nektro/zig-git commit-103f4e419c35b88f802bb8234ece1c0a9aa40c03 git https://github.com/nektro/zig-inquirer commit-9e1d873db79e9ffa6ae6e06bd372428c9be85d97 git https://github.com/nektro/zig-leven commit-e548b0bcc7b6f34f636c0b6b905928d31254c54d git https://github.com/nektro/zig-licenses commit-f46d9f774df929885eef66c733a1e2a46bf16aec git https://github.com/nektro/zig-licenses-text commit-b01e5a2dffcc564bddd8f514fe64bab9b5c52572 git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e0415992 git https://github.com/nektro/zig-time commit-ba546bbf2e8438c9b2325f36f392c9d95b432e8e +git https://github.com/nektro/zig-tracer commit-ad868b45cfd445aa4d3f53cf8dda4b62b73efb54 git https://github.com/nektro/zig-yaml commit-0d17fb99cba338aedc1abac12d78d5e5f04f0b6b git https://github.com/truemedian/hzzp commit-a7f03a1e652abe8c89b376d090cec50acb0d2a1a git https://github.com/ziglibs/known-folders commit-0ad514dcfb7525e32ae349b9acc0a53976f3a9fa