From f545fc28b35b454b2b0167ede45aeacc0cd93387 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 18 Dec 2023 14:43:07 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 2 +- build.zig | 9 ++++++++- ci/aarch64-linux-debug.sh | 1 - ci/aarch64-linux-release.sh | 1 - ci/aarch64-macos-debug.sh | 1 - ci/aarch64-macos-release.sh | 1 - ci/aarch64-windows.ps1 | 1 - ci/x86_64-linux-debug.sh | 1 - ci/x86_64-linux-release.sh | 1 - ci/x86_64-macos-release.sh | 1 - ci/x86_64-windows-debug.ps1 | 1 - ci/x86_64-windows-release.ps1 | 1 - 12 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e9e20262e..b5f9c02377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ if("${ZIG_VERSION}" STREQUAL "") find_program(GIT_EXE NAMES git NAMES_PER_DIR) if(GIT_EXE) execute_process( - COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags + COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags --abbrev=9 RESULT_VARIABLE EXIT_STATUS OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/build.zig b/build.zig index 19721764f3..11b3006039 100644 --- a/build.zig +++ b/build.zig @@ -263,7 +263,14 @@ pub fn build(b: *std.Build) !void { var code: u8 = undefined; const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{ - "git", "-C", b.build_root.path orelse ".", "describe", "--match", "*.*.*", "--tags", + "git", + "-C", + b.build_root.path orelse ".", + "describe", + "--match", + "*.*.*", + "--tags", + "--abbrev=9", }, &code, .Ignore) catch { break :v version_string; }; diff --git a/ci/aarch64-linux-debug.sh b/ci/aarch64-linux-debug.sh index dd258e0881..3ffe2c1101 100644 --- a/ci/aarch64-linux-debug.sh +++ b/ci/aarch64-linux-debug.sh @@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH" # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh index 25118bce82..9b118b6ba9 100644 --- a/ci/aarch64-linux-release.sh +++ b/ci/aarch64-linux-release.sh @@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH" # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/aarch64-macos-debug.sh b/ci/aarch64-macos-debug.sh index adf988edc4..33712cefdf 100755 --- a/ci/aarch64-macos-debug.sh +++ b/ci/aarch64-macos-debug.sh @@ -17,7 +17,6 @@ cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/aarch64-macos-release.sh b/ci/aarch64-macos-release.sh index 22dae5b4a2..b3b82180e5 100755 --- a/ci/aarch64-macos-release.sh +++ b/ci/aarch64-macos-release.sh @@ -17,7 +17,6 @@ cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/aarch64-windows.ps1 b/ci/aarch64-windows.ps1 index 0a21646713..c0d97c98f9 100644 --- a/ci/aarch64-windows.ps1 +++ b/ci/aarch64-windows.ps1 @@ -24,7 +24,6 @@ function CheckLastExitCode { # Make the `zig version` number consistent. # This will affect the `zig build` command below which uses `git describe`. -git config core.abbrev 9 git fetch --tags if ((git rev-parse --is-shallow-repository) -eq "true") { diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh index 6f3ebf642d..da0b3f8b06 100755 --- a/ci/x86_64-linux-debug.sh +++ b/ci/x86_64-linux-debug.sh @@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64 # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh index 22222c7740..7317026bea 100755 --- a/ci/x86_64-linux-release.sh +++ b/ci/x86_64-linux-release.sh @@ -16,7 +16,6 @@ export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64 # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/x86_64-macos-release.sh b/ci/x86_64-macos-release.sh index c773cab348..3db3f96773 100755 --- a/ci/x86_64-macos-release.sh +++ b/ci/x86_64-macos-release.sh @@ -22,7 +22,6 @@ cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. -git config core.abbrev 9 git fetch --unshallow || true git fetch --tags diff --git a/ci/x86_64-windows-debug.ps1 b/ci/x86_64-windows-debug.ps1 index dec3a4be22..c1ae92494e 100644 --- a/ci/x86_64-windows-debug.ps1 +++ b/ci/x86_64-windows-debug.ps1 @@ -23,7 +23,6 @@ function CheckLastExitCode { # Make the `zig version` number consistent. # This will affect the `zig build` command below which uses `git describe`. -git config core.abbrev 9 git fetch --tags if ((git rev-parse --is-shallow-repository) -eq "true") { diff --git a/ci/x86_64-windows-release.ps1 b/ci/x86_64-windows-release.ps1 index c306756bd2..988402606b 100644 --- a/ci/x86_64-windows-release.ps1 +++ b/ci/x86_64-windows-release.ps1 @@ -23,7 +23,6 @@ function CheckLastExitCode { # Make the `zig version` number consistent. # This will affect the `zig build` command below which uses `git describe`. -git config core.abbrev 9 git fetch --tags if ((git rev-parse --is-shallow-repository) -eq "true") {