Skip to content

Without tags/history can we fall back to the version file? #104

@peircej

Description

@peircej

In my project we're setting project/VERSION and reading that in as the basis for file-based versioning using

[tool.setuptools-git-versioning]
enabled = true
version_file = "project/VERSION" 
count_commits_from_version_file = true
dev_template = "{tag}.{branch}{ccount}"
branch_formatter = "utils:_branchFormatter" 

(branch formatter is there to sanitize branch name to something valid for a version)

Now, if we do clone with depth=1, we get an invalid versions like 2024.1.0devNone because it couldn't find either a tag distance or a commit distance. It would be great if, when no distance was found it simply returned the contents of the VERSION file (or 2024.1.0dev0. Basically, I want it always to be something valid no matter how they've fetched the project. Is this something that needs a custom version callback?

The project in question has over 900 forks so if it doesn't "just work" in all common cases then contributors are going to hit annoying barriers.

I think my current workaround is going to be to leave setuptools-git-versioning out of the main repo (for safety/compatibility) and just install it in the CI build system, when generating our official releases. But if I could set it up to work safely in all places that would feel neater.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions