authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-02-01 03:02:48 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-02-01 03:02:48 -08:00
log1e9aa3d5bd87db2a7a661d75eff32c7c6bcbd37e
tree6b69781fd98db9a0506919169bb9ea37e2208090
parent4d2a6db4840ab1bf10169e4fdff5acd5f1a967a3

initial code implementation


2 files changed, 17 insertions(+), 0 deletions(-)

git.zig created+11
......@@ -0,0 +1,11 @@
1const std = @import("std");
2const string = []const u8;
3
4/// Returns the result of running `git rev-parse HEAD`
5pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !string {
6 var dirg = try dir.openDir(".git", .{});
7 defer dirg.close();
8 const h = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, "HEAD", 1024), "\n");
9 const r = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, h[5..], 1024), "\n");
10 return r;
11}
zig.mod created+6
......@@ -0,0 +1,6 @@
1id: 0k64oe2nuzvjgz226ufvimjhialghxdgmlzusonbma31flnd
2name: git
3main: git.zig
4license: MIT
5description: Inspect into the depths of your .git folder purely from Zig
6dependencies: