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 {...@@ -119,7 +119,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
119 for (list.items) |m| {119 for (list.items) |m| {
120 if (m.dep) |md| {120 if (m.dep) |md| {
121 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });121 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));
123 try wl.print("{s} {s} {s} {s}\n", .{ m.clean_path, @tagName(md.type), md.path, version });123 try wl.print("{s} {s} {s} {s}\n", .{ m.clean_path, @tagName(md.type), md.path, version });
124 }124 }
125 }125 }
src/util/dep_type.zig+1-1
...@@ -78,7 +78,7 @@ pub const DepType = enum {...@@ -78,7 +78,7 @@ pub const DepType = enum {
78 return switch (self) {78 return switch (self) {
79 .local => "",79 .local => "",
80 .system_lib => "",80 .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]}),
82 .hg => "",82 .hg => "",
83 .http => "",83 .http => "",
84 };84 };
src/util/funcs.zig+2-2
...@@ -255,7 +255,7 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 {...@@ -255,7 +255,7 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]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, .{});256 const dir = try std.fs.cwd().openDir(path, .{});
257 const dirg = try dir.openDir(".git", .{});257 const dirg = try dir.openDir(".git", .{});
258 const h = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n");258 const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", max), "\n");
259 const r = std.mem.trimRight(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");259 const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");
260 return r;260 return r;
261}261}