| 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,10 +75,12 @@ pub const DepType = enum { |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | pub fn exact_version(self: DepType, mpath: []const u8) ![]const u8 { | 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 | return switch (self) { | 80 | return switch (self) { |
| 79 | .local => "", | 81 | .local => "", |
| 80 | .system_lib => "", | 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 | .hg => "", | 84 | .hg => "", |
| 83 | .http => "", | 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,9 +251,8 @@ pub fn do_hash(comptime algo: type, data: []const u8) ![]const u8 { |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /// Returns the result of running `git rev-parse HEAD` | 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 | const max = std.math.maxInt(usize); | 255 | const max = std.math.maxInt(usize); |
| 256 | const dir = try std.fs.cwd().openDir(path, .{}); | ||
| 257 | const dirg = try dir.openDir(".git", .{}); | 256 | const dirg = try dir.openDir(".git", .{}); |
| 258 | const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n"); | 257 | const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n"); |
| 259 | const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n"); | 258 | const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n"); |