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

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

Open
peircej opened this issue Jul 9, 2024 · 1 comment
Open

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

peircej opened this issue Jul 9, 2024 · 1 comment

Comments

@peircej
Copy link

peircej commented Jul 9, 2024

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.

@dolfinus
Copy link
Owner

PRs are welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants