carvel-dev / carvel-dev/vendir

Support tilde in semver constraints

Open
#172 5 comments 0 reactions 0 assignees View on GitHub
carvel-accepted enhancement priority/important-longterm
Dominant language
Go
Stars
399
Forks
73
Avg merge
2h 53m
Merged PRs (30d)
2

Description

**Describe the problem/challenge you have**
I want to support 1.2.x for a given version, including pre-releases, but given something like this:

```
1.1.1
1.1.2
1.2.0
1.2.10-build.1
1.2.10
1.2.100-build.20
1.2.100
1.3.0-build.1
1.3.0-build.2
```

It's hard to figure out where to put the <, since `1.3.0-build.x` is considered less than 1.3.0

```
vendir tools sort-semver -v "1.1.1 1.1.2 1.2.0 1.2.10-build.1 1.2.10 1.2.100-build.20 1.2.100 1.3.0-build.1 1.3.0-build.2" -c "<1.3.0" --prerelease --prerelease-identifier "build"
Versions

Version
1.1.1
1.1.2
1.2.0
1.2.10-build.1
1.2.10
1.2.100-build.20
1.2.100
1.3.0-build.1
1.3.0-build.2

Highest version: 1.3.0-build.2

Succeeded
```
Changing it to something like:
```
vendir tools sort-semver -v "1.1.1 1.1.2 1.2.0 1.2.10-build.1 1.2.10 1.2.100-build.20 1.2.100 1.3.0-build.1 1.3.0-build.2" -c "<1.2.10" --prerelease --prerelease-identifier "build"
```
Causes you to miss the high numbers of `1.2.x`.

**Describe the solution you'd like**
`~` exists in several upstream semver libraries, so you can do something like:

```
~1.2
```
And it'll work for all patch versions of 1.2, but exclude anything in 1.3 or higher.

**Anything else you would like to add:**
While this is extremely unlikely in the exemplified upstream product (TAP), I wanted to capture this in case the scenario becomes increasingly likely. Pretty sure my use case is satisified by just picking something like 1000 for the patch release (I'm actually just using 1.2.9 now since that also seems likely to work)

---
Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

Contributor guide

Open the contributing guide

Research direction

Start with the `vendir tools sort-semver` command and its existing constraint parsing, then run the examples from the issue with prerelease filtering enabled. Done means `~1.2` accepts all 1.2 patch versions, including matching prereleases, while excluding 1.3 and higher.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.