From 6b69c61040f9c298166fe3c2e4e29109e5b1834e Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Mon, 16 Aug 2021 21:34:51 +0100 Subject: [PATCH] Specify length of git hash prefix used in build info version fix #4855 Signed-off-by: Josh Berdine --- CHANGES.md | 3 +++ bin/subst.ml | 4 ++-- boot/duneboot.ml | 3 ++- doc/dune-libs.rst | 2 +- doc/usage.rst | 4 ++-- src/dune_engine/vcs.ml | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e6d6b590520..b20e6fe363e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -168,6 +168,9 @@ Unreleased executable with missing libraries as optional. Now, we treat make sure to look at the library's optional or enabled_if status (#4786). +- Always use 7 char hash prefix in build info version (#4857, @jberdine, fixes + #4855) + 2.9.1 (unreleased) ------------------ diff --git a/bin/subst.ml b/bin/subst.ml index 291e90b9fef..d71868512fa 100644 --- a/bin/subst.ml +++ b/bin/subst.ml @@ -26,12 +26,12 @@ let man = ^ {|) strings by the version obtained from the vcs. Currently only git is supported and the version is obtained from the output of:|} ) - ; `Pre {| \$ git describe --always --dirty|} + ; `Pre {| \$ git describe --always --dirty --abbrev=7|} ; `P {|$(b,dune subst) substitutes the variables that topkg substitutes with the default configuration:|} ; var "NAME" "the name of the project (from the dune-project file)" - ; var "VERSION" "output of $(b,git describe --always --dirty)" + ; var "VERSION" "output of $(b,git describe --always --dirty --abbrev=7)" ; var "VERSION_NUM" ("same as $(b," ^ literal_version ^ ") but with a potential leading 'v' or 'V' dropped") diff --git a/boot/duneboot.ml b/boot/duneboot.ml index 6e5d12290a8..628b7792c03 100644 --- a/boot/duneboot.ml +++ b/boot/duneboot.ml @@ -697,7 +697,8 @@ module Build_info = struct if not (Sys.file_exists ".git") then Fiber.return None else - Process.try_run_and_capture "git" [ "describe"; "--always"; "--dirty" ] + Process.try_run_and_capture "git" + [ "describe"; "--always"; "--dirty"; "--abbrev=7" ] >>| function | Some s -> Some (String.trim s) | None -> None) diff --git a/doc/dune-libs.rst b/doc/dune-libs.rst index 381fe1dd1ef..d8f30f0a9ef 100644 --- a/doc/dune-libs.rst +++ b/doc/dune-libs.rst @@ -152,7 +152,7 @@ repositories: .. code:: bash - git describe --always --dirty + git describe --always --dirty --abbrev=7 which produces a human readable version string of the form ``--[-dirty]``. diff --git a/doc/usage.rst b/doc/usage.rst index 291308b3aa1..c9db2fe6e23 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -418,7 +418,7 @@ git, dune-release invokes this command to find out the version: .. code:: bash - $ git describe --always --dirty + $ git describe --always --dirty --abbrev=7 1.0+beta9-79-g29e9b37 Projects using dune usually only need dune-release for creating and @@ -434,7 +434,7 @@ project. More precisely, it replaces all the following watermarks in source files: - ``NAME``, the name of the project -- ``VERSION``, output of ``git describe --always --dirty`` +- ``VERSION``, output of ``git describe --always --dirty --abbrev=7`` - ``VERSION_NUM``, same as ``VERSION`` but with a potential leading ``v`` or ``V`` dropped - ``VCS_COMMIT_ID``, commit hash from the vcs diff --git a/src/dune_engine/vcs.ml b/src/dune_engine/vcs.ml index b16a09c0225..8e4d99270bf 100644 --- a/src/dune_engine/vcs.ml +++ b/src/dune_engine/vcs.ml @@ -116,7 +116,8 @@ let make_fun name ~git ~hg = let describe = Staged.unstage @@ make_fun "vcs-describe" - ~git:(fun t -> run_git t [ "describe"; "--always"; "--dirty" ]) + ~git:(fun t -> + run_git t [ "describe"; "--always"; "--dirty"; "--abbrev=7" ]) ~hg:(fun x -> let open Fiber.O in let+ res = hg_describe x in