authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-18 14:43:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-19 00:54:48-08:00
logf545fc28b35b454b2b0167ede45aeacc0cd93387
tree4c71ae6e0cc5ffa16c2eb14a9f8c166524c2bf06
parent90a19f74116eb09e4711d845d08c011cb62b8cbf

build: pass --abbrev to git rather than relying on global config

For computing the zig version number, pass --abbrev=9 rather than requiring the user to set their git configuration in order to make zig versions match the standard.

12 files changed, 9 insertions(+), 12 deletions(-)

CMakeLists.txt+1-1
......@@ -45,7 +45,7 @@ if("${ZIG_VERSION}" STREQUAL "")
4545 find_program(GIT_EXE NAMES git NAMES_PER_DIR)
4646 if(GIT_EXE)
4747 execute_process(
48 COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags
48 COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags --abbrev=9
4949 RESULT_VARIABLE EXIT_STATUS
5050 OUTPUT_VARIABLE GIT_DESCRIBE
5151 OUTPUT_STRIP_TRAILING_WHITESPACE
build.zig+8-1
......@@ -263,7 +263,14 @@ pub fn build(b: *std.Build) !void {
263263
264264 var code: u8 = undefined;
265265 const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{
266 "git", "-C", b.build_root.path orelse ".", "describe", "--match", "*.*.*", "--tags",
266 "git",
267 "-C",
268 b.build_root.path orelse ".",
269 "describe",
270 "--match",
271 "*.*.*",
272 "--tags",
273 "--abbrev=9",
267274 }, &code, .Ignore) catch {
268275 break :v version_string;
269276 };
ci/aarch64-linux-debug.sh-1
......@@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
1616
1717# Make the `zig version` number consistent.
1818# This will affect the cmake command below.
19git config core.abbrev 9
2019git fetch --unshallow || true
2120git fetch --tags
2221
ci/aarch64-linux-release.sh-1
......@@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
1616
1717# Make the `zig version` number consistent.
1818# This will affect the cmake command below.
19git config core.abbrev 9
2019git fetch --unshallow || true
2120git fetch --tags
2221
ci/aarch64-macos-debug.sh-1
......@@ -17,7 +17,6 @@ cd $ZIGDIR
1717
1818# Make the `zig version` number consistent.
1919# This will affect the cmake command below.
20git config core.abbrev 9
2120git fetch --unshallow || true
2221git fetch --tags
2322
ci/aarch64-macos-release.sh-1
......@@ -17,7 +17,6 @@ cd $ZIGDIR
1717
1818# Make the `zig version` number consistent.
1919# This will affect the cmake command below.
20git config core.abbrev 9
2120git fetch --unshallow || true
2221git fetch --tags
2322
ci/aarch64-windows.ps1-1
......@@ -24,7 +24,6 @@ function CheckLastExitCode {
2424
2525# Make the `zig version` number consistent.
2626# This will affect the `zig build` command below which uses `git describe`.
27git config core.abbrev 9
2827git fetch --tags
2928
3029if ((git rev-parse --is-shallow-repository) -eq "true") {
ci/x86_64-linux-debug.sh-1
......@@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64
1616
1717# Make the `zig version` number consistent.
1818# This will affect the cmake command below.
19git config core.abbrev 9
2019git fetch --unshallow || true
2120git fetch --tags
2221
ci/x86_64-linux-release.sh-1
......@@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64
1616
1717# Make the `zig version` number consistent.
1818# This will affect the cmake command below.
19git config core.abbrev 9
2019git fetch --unshallow || true
2120git fetch --tags
2221
ci/x86_64-macos-release.sh-1
......@@ -22,7 +22,6 @@ cd $ZIGDIR
2222
2323# Make the `zig version` number consistent.
2424# This will affect the cmake command below.
25git config core.abbrev 9
2625git fetch --unshallow || true
2726git fetch --tags
2827
ci/x86_64-windows-debug.ps1-1
......@@ -23,7 +23,6 @@ function CheckLastExitCode {
2323
2424# Make the `zig version` number consistent.
2525# This will affect the `zig build` command below which uses `git describe`.
26git config core.abbrev 9
2726git fetch --tags
2827
2928if ((git rev-parse --is-shallow-repository) -eq "true") {
ci/x86_64-windows-release.ps1-1
......@@ -23,7 +23,6 @@ function CheckLastExitCode {
2323
2424# Make the `zig version` number consistent.
2525# This will affect the `zig build` command below which uses `git describe`.
26git config core.abbrev 9
2726git fetch --tags
2827
2928if ((git rev-parse --is-shallow-repository) -eq "true") {