| author | |
| committer | |
| log | 3027dfad1d9d8e7bb8c647893b82197c3101932c |
| tree | 201e50587ceb607cd4035ecc4bd633333447c11c |
| parent | 8be6116dd04477d4f967c09bfe3c560b7f3da15b |
3 files changed, 23 insertions(+), 1 deletions(-)
src/cmd/fetch.zig+1-1| ... | @@ -128,7 +128,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void { | ... | @@ -128,7 +128,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void { |
| 128 | } | 128 | } |
| 129 | if (md.type == .system_lib) continue; | 129 | if (md.type == .system_lib) continue; |
| 130 | const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path }); | 130 | const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path }); |
| 131 | const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath)); | 131 | const version = try md.exact_version(mpath); |
| 132 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); | 132 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
src/util/dep.zig+14| ... | @@ -57,4 +57,18 @@ pub const Dep = struct { | ... | @@ -57,4 +57,18 @@ pub const Dep = struct { |
| 57 | } | 57 | } |
| 58 | return true; | 58 | return true; |
| 59 | } | 59 | } |
| 60 | |||
| 61 | pub fn exact_version(self: Dep, dpath: []const u8) ![]const u8 { | ||
| 62 | if (self.version.len == 0) { | ||
| 63 | return try self.type.exact_version(dpath); | ||
| 64 | } | ||
| 65 | return switch (self.type) { | ||
| 66 | .git => blk: { | ||
| 67 | const vers = try u.parse_split(u.GitVersionType, "-").do(self.version); | ||
| 68 | if (vers.id.frozen()) break :blk self.version; | ||
| 69 | break :blk try self.type.exact_version(dpath); | ||
| 70 | }, | ||
| 71 | else => self.version, | ||
| 72 | }; | ||
| 73 | } | ||
| 60 | }; | 74 | }; |
src/util/dep_type.zig+8| ... | @@ -94,4 +94,12 @@ pub const GitVersionType = enum { | ... | @@ -94,4 +94,12 @@ pub const GitVersionType = enum { |
| 94 | branch, | 94 | branch, |
| 95 | tag, | 95 | tag, |
| 96 | commit, | 96 | commit, |
| 97 | |||
| 98 | pub fn frozen(self: GitVersionType) bool { | ||
| 99 | return switch (self) { | ||
| 100 | .branch => false, | ||
| 101 | .tag => true, | ||
| 102 | .commit => true, | ||
| 103 | }; | ||
| 104 | } | ||
| 97 | }; | 105 | }; |