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 2 admin commands to compare 2 package versions #6196

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbarbin
Copy link
Contributor

@mbarbin mbarbin commented Sep 13, 2024

Add 2 new commands opam admin {assert-}compare-versions to compare package versions for sanity checks.

  1. compare-versions - User interactive.

In this command, we provide two versions, and opam outputs a user-friendly expression with the result of the comparison, spelled out. For example:

$ opam admin compare-versions 0.0.9 0.0.10
 0.0.9 < 0.0.10

The command exits 0 regardless of the result of the comparison.

  1. assert-compare-versions - For use in scripts, if needed.

This command is silent, and requires an operator {lt,le,eq}. The result of the command will be encoded in the exit code, to be used in bash conditionals:

exit 0: the comparison holds
exit 1: it doesn't

For example:

$ opam admin assert-compare-versions 0.0.9 lt 0.0.10
[0]

$ opam admin assert-compare-versions 0.2.2 le 0.2.0
[1]

This PR is an alternative to #6124 trying to account for the various feedback received.

This is meant for quick sanity checks for example.

- Added some basic tests to cover the commands.

Signed-off-by: Mathieu Barbin <[email protected]>
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 this pull request may close these issues.

1 participant