authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-06 11:02:32 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-06 11:02:32 -07:00
log292acfc7a2d4f279b380cd1544d8b3beab0fe99b
tree3756c695ca7167ff20ee584ab72afbf43897b8e1
parentb2a1b0177e348968417799b578792647750cd7b4

trim newlines on both sides of file reads of .git folder


3 files changed, 4 insertions(+), 4 deletions(-)

src/cmd/fetch.zig+1-1
......@@ -119,7 +119,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
119119 for (list.items) |m| {
120120 if (m.dep) |md| {
121121 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });
122 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath))[0..14];
122 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath));
123123 try wl.print("{s} {s} {s} {s}\n", .{ m.clean_path, @tagName(md.type), md.path, version });
124124 }
125125 }
src/util/dep_type.zig+1-1
......@@ -78,7 +78,7 @@ pub const DepType = enum {
7878 return switch (self) {
7979 .local => "",
8080 .system_lib => "",
81 .git => try std.fmt.allocPrint(gpa, "commit-{s}", .{try u.git_rev_HEAD(gpa, mpath)}),
81 .git => try std.fmt.allocPrint(gpa, "commit-{s}", .{(try u.git_rev_HEAD(gpa, mpath))[0..7]}),
8282 .hg => "",
8383 .http => "",
8484 };
src/util/funcs.zig+2-2
......@@ -255,7 +255,7 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 {
255255 const max = std.math.maxInt(usize);
256256 const dir = try std.fs.cwd().openDir(path, .{});
257257 const dirg = try dir.openDir(".git", .{});
258 const h = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n");
259 const r = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");
258 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");
260260 return r;
261261}