Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify length of git hash prefix used in build info version #4857

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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