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

Add semver_lt/semver_gt/semver_eq/... functions #1712

Closed
t3hmrman opened this issue Oct 26, 2023 · 3 comments · Fixed by #1713
Closed

Add semver_lt/semver_gt/semver_eq/... functions #1712

t3hmrman opened this issue Oct 26, 2023 · 3 comments · Fixed by #1713

Comments

@t3hmrman
Copy link
Contributor

t3hmrman commented Oct 26, 2023

Thanks for the awesome tool -- just has been a huge part of my daily workflow and I take it to "just" about every project I start now.

One thing I've often run into is the need to parse & check versions of dependencies cross-language/toolchain against each other, and checking/ensuring a certain version of semver often comes up.

For exact matches this is relatively simple, but it might be nice to do be able to do this a bit more semantically as a utility within just.

A somewhat contrived example of what I'd like to be able to do is:

dep := env_var_or_default("DEP", "dep")
dep_version := `dep --version` # let's pretend that this prints the semver version
dep_version_supported := if semver_gte(dep_version, "0.2.0") { "supported" } else { "not supported" }

check:
  echo "your dep version of dep ({{dep_version}}) is {{dep_version_supported}}"

Does this seem like something that makes sense as a part of just?

@casey
Copy link
Owner

casey commented Oct 26, 2023

This seems reasonable to me, although I'm definitely curious if other people would find this useful, since it seems a little niche to me.

We could get away with having a single function, semver_match. The semver spec can have an = in front of it, to assert that it's an exact match, e.g., semver_match(version, "=1.0.0"). I think this is supported by the semver rust library.

@casey
Copy link
Owner

casey commented Oct 26, 2023

And thank you for the kind words! I'm always super happy when people find just useful.

@t3hmrman
Copy link
Contributor Author

This seems reasonable to me, although I'm definitely curious if other people would find this useful, since it seems a little niche to me.

Agreed -- I kind of squared this by thinking of it like a string manipulation problem? It's definitely unclear if it's something a ton of people want though...

We could get away with having a single function, semver_match. The semver spec can have an = in front of it, to assert that it's an exact match, e.g., semver_match(version, "=1.0.0"). I think this is supported by the semver rust library.

This would be much better, great idea -- I'll put up a PR with this setup.

And thank you for the kind words! I'm always super happy when people find just useful.

Absolutely no problem, useful is an understatement!

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

Successfully merging a pull request may close this issue.

2 participants