| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | |
| 4 | /// Returns the result of running `git rev-parse HEAD` |
| 5 | pub 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 | } |