Skip to content

dune subst inferred version is totally misleading and wrong #11542

@toots

Description

@toots

We were debugging several user builds of our code base and were faced with a spread of totally confusing versions returned from building from a git checkout.

Turns out that dune subst uses the following command to infer dev versions:

git describe --always --dirty --abbrev=7

But this command produces descriptions that are absolutely misleading. Here's an example:

% git describe --always --dirty --abbrev=7 --debug                                                                                                                   
describe HEAD
No exact match on refs or tags, searching to describe
finished search at 6eba12641e468c435114b2afc8763211f41b168a
 annotated        888 v2.2.0
traversed 889 commits
v2.2.0-888-g748cd0c

This is using a commit that is 889 commits (!!) behind the current main (!) branch to describe it and using the versioned tag, which would have you wrongly assume that this is a build for that version.

Also that g prefix before the commit is really misleading as well.

Lastly, tags are by definition moving pieces in git repo. Typically, a release tag can be force-pushed and etc. They are not very useful to have a reliable version. A commit SHA would be much better.

This command should be tightened to return something closer to the current commit. I would expect that most people simply want the current branch name, if it exist, and/or the commit, something like:

[<branch-name>|<tag name>-]-git@<commit SHA>

At the very least, the command should be updated to:

  • Include all tags (some git clones don't have them all locally checked out)
  • Limit the number of commit to look for. I'd frankly suggest just one!

This gives:

git describe --always --dirty --abbrev=7 --candidates=1 --tags

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolsInternal dune tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions