| author | |
| committer | |
| log | 4c50d70fc94e765b1bf7b5e13f629ee1eea887e4 |
| tree | d653522ad4d91b5453812ddde1a0fee471c4a3da |
| parent | b4add621bf8f306a27151db9699f7368d8da02c8 |
2 files changed, 4 insertions(+), 3 deletions(-)
src/util/dep_type.zig+3-1| ... | ... | @@ -75,10 +75,12 @@ pub const DepType = enum { |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | pub fn exact_version(self: DepType, mpath: []const u8) ![]const u8 { |
| 78 | var mdir = try std.fs.cwd().openDir(mpath, .{}); | |
| 79 | defer mdir.close(); | |
| 78 | 80 | return switch (self) { |
| 79 | 81 | .local => "", |
| 80 | 82 | .system_lib => "", |
| 81 | .git => try std.fmt.allocPrint(gpa, "commit-{s}", .{(try u.git_rev_HEAD(gpa, mpath))[0..7]}), | |
| 83 | .git => try std.fmt.allocPrint(gpa, "commit-{s}", .{(try u.git_rev_HEAD(gpa, mdir))[0..7]}), | |
| 82 | 84 | .hg => "", |
| 83 | 85 | .http => "", |
| 84 | 86 | }; |
src/util/funcs.zig+1-2| ... | ... | @@ -251,9 +251,8 @@ pub fn do_hash(comptime algo: type, data: []const u8) ![]const u8 { |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /// Returns the result of running `git rev-parse HEAD` |
| 254 | pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 { | |
| 254 | pub fn git_rev_HEAD(alloc: *std.mem.Allocator, dir: std.fs.Dir) ![]const u8 { | |
| 255 | 255 | const max = std.math.maxInt(usize); |
| 256 | const dir = try std.fs.cwd().openDir(path, .{}); | |
| 257 | 256 | const dirg = try dir.openDir(".git", .{}); |
| 258 | 257 | const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n"); |
| 259 | 258 | const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n"); |