| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 2 | 3 | const gpa = std.heap.c_allocator; |
| 3 | 4 | const builtin = @import("builtin"); |
| 4 | 5 | |
| ... | ... | @@ -14,19 +15,17 @@ pub fn execute(args: [][]u8) !void { |
| 14 | 15 | const build_options = if (@hasDecl(root, "build_options")) root.build_options else struct {}; |
| 15 | 16 | const version = if (@hasDecl(build_options, "version")) build_options.version else "unknown"; |
| 16 | 17 | |
| 18 | var gitversion = u.git_rev_HEAD(gpa, std.fs.cwd()) catch ""; |
| 19 | gitversion = if (gitversion.len > 0) gitversion[0..7] else gitversion; |
| 20 | |
| 17 | 21 | const stdout = std.io.getStdOut(); |
| 18 | 22 | const w = stdout.writer(); |
| 19 | 23 | |
| 20 | 24 | try w.writeAll("zigmod"); |
| 21 | 25 | |
| 22 | 26 | try w.print(" {s}", .{version}); |
| 23 | | if (std.mem.eql(u8, version, "dev")) { |
| 24 | | try w.print( |
| 25 | | "-{s}", |
| 26 | | .{ |
| 27 | | (try u.git_rev_HEAD(gpa, std.fs.cwd()))[0..7], |
| 28 | | }, |
| 29 | | ); |
| 27 | if (std.mem.eql(u8, version, "dev") and gitversion.len > 0) { |
| 28 | try w.print("-{s}", .{gitversion}); |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | 31 | try w.print(" {s}", .{@tagName(builtin.os.tag)}); |