Skip to content

Commit 19b5744

Browse files
committed
Specify length of git hash prefix used in build info version
fix #4855 Signed-off-by: Josh Berdine <josh@berdine.net>
1 parent 05b1a9a commit 19b5744

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

bin/subst.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ let man =
2626
^ {|) strings by the version obtained from the vcs. Currently only git is
2727
supported and the version is obtained from the output of:|}
2828
)
29-
; `Pre {| \$ git describe --always --dirty|}
29+
; `Pre {| \$ git describe --always --dirty --abbrev=7|}
3030
; `P
3131
{|$(b,dune subst) substitutes the variables that topkg substitutes with
3232
the default configuration:|}
3333
; var "NAME" "the name of the project (from the dune-project file)"
34-
; var "VERSION" "output of $(b,git describe --always --dirty)"
34+
; var "VERSION" "output of $(b,git describe --always --dirty --abbrev=7)"
3535
; var "VERSION_NUM"
3636
("same as $(b," ^ literal_version
3737
^ ") but with a potential leading 'v' or 'V' dropped")

boot/duneboot.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ module Build_info = struct
697697
if not (Sys.file_exists ".git") then
698698
Fiber.return None
699699
else
700-
Process.try_run_and_capture "git" [ "describe"; "--always"; "--dirty" ]
700+
Process.try_run_and_capture "git"
701+
[ "describe"; "--always"; "--dirty"; "--abbrev=7" ]
701702
>>| function
702703
| Some s -> Some (String.trim s)
703704
| None -> None)

doc/dune-libs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ repositories:
152152

153153
.. code:: bash
154154
155-
git describe --always --dirty
155+
git describe --always --dirty --abbrev=7
156156
157157
which produces a human readable version string of the form
158158
``<version>-<commits-since-version>-<hash>[-dirty]``.

doc/usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ git, dune-release invokes this command to find out the version:
418418

419419
.. code:: bash
420420
421-
$ git describe --always --dirty
421+
$ git describe --always --dirty --abbrev=7
422422
1.0+beta9-79-g29e9b37
423423
424424
Projects using dune usually only need dune-release for creating and
@@ -434,7 +434,7 @@ project.
434434
More precisely, it replaces all the following watermarks in source files:
435435

436436
- ``NAME``, the name of the project
437-
- ``VERSION``, output of ``git describe --always --dirty``
437+
- ``VERSION``, output of ``git describe --always --dirty --abbrev=7``
438438
- ``VERSION_NUM``, same as ``VERSION`` but with a potential leading
439439
``v`` or ``V`` dropped
440440
- ``VCS_COMMIT_ID``, commit hash from the vcs

src/dune_engine/vcs.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ let make_fun name ~git ~hg =
116116
let describe =
117117
Staged.unstage
118118
@@ make_fun "vcs-describe"
119-
~git:(fun t -> run_git t [ "describe"; "--always"; "--dirty" ])
119+
~git:(fun t ->
120+
run_git t [ "describe"; "--always"; "--dirty"; "--abbrev=7" ])
120121
~hg:(fun x ->
121122
let open Fiber.O in
122123
let+ res = hg_describe x in

0 commit comments

Comments
 (0)