Partial version number tags in SwiftPM

I'm experimenting with integrating SwiftPM into existing C++ projects. One issue I'm hitting is that some of these projects are already tagging their Git repos with semantic versions, but are leaving off the patch version when it's 0. For example, I might see a project with tags:

1.0
1.1
1.2
1.2.1

This seems to be a really common style from various authors in different repos.

I was thinking about contributing a patch to fix this issue, but this seems like something that may have already been considered by the SwiftPM community. I've tried searching, but I can't find any conversation on this topic.

Is there a reason that these truncated version numbers don't seem to be supported by SwiftPM? Changing SwiftPM to support this pattern is a lot easier than changing all the developers working on their own repos. But if this was already considered and rejected for a reason, I don't want to work through patch + pull request.

Not sure if we previously discussed this in detail, but one issue that comes to mind is that this allows ambiguity, because now it is possible for both "1.0" and "1.0.0" to exist.

1 Like

Looking through the code, it looks like there is already some consideration for the multiple conflicting tags scenario. For example, SPM treats both v1.0.0 and 1.0.0 as valid, but both could point to two different commits. Within RepositoryPackageContainer.swift, it looks like there is some thought about this around line 99.

I think I'm going to test out a patch for implementing this behavior based on the existing ambiguity handling, and maybe go open a pull request if it works out. Happy to keep discussing this here as well if there are concerns that this should not be implemented by the maintainers.

I started down the path of implementing this, but realized version string parsing is part of swift-tools-support-core. I have a pull request to possibly introduce this more lenient parsing into the Version type here:

Terms of Service

Privacy Policy

Cookie Policy