Skip to content

Commit

Permalink
Specify length of git hash prefix used in build info version
Browse files Browse the repository at this point in the history
fix #4855

Signed-off-by: Josh Berdine <[email protected]>
  • Loading branch information
jberdine authored and rgrinberg committed Aug 17, 2021
1 parent 05b1a9a commit 6b69c61
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------

Expand Down
4 changes: 2 additions & 2 deletions bin/subst.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion boot/duneboot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doc/dune-libs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
``<version>-<commits-since-version>-<hash>[-dirty]``.
Expand Down
4 changes: 2 additions & 2 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/dune_engine/vcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b69c61

Please sign in to comment.