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

Bugfix/semver lt #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lauguillier
Copy link

Use bash in shebang
Fix shellcheck errors and warning
Fix a bug in semverLT:

There was a bug in semverLT(), when both versions
have a special field, semverLT would just compare
that special field if majorA > majorB

Before fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 0. <- Offending result!
8.4.2-12 > 6.90.5-13 -> 1. <- Side effect because GT uses LT

After fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 1. <- Correct
8.4.2-12 > 6.90.5-13 -> 0.

Laurent Guillier added 2 commits November 30, 2023 09:31
Use bash in shebang
use [[ ]] for tests
remove 'function' keyword
Fix shellcheck errors and warnings
There was a bug in semverLT(), when both versions
have a special field, semverLT would just compare
that special field if majorA > majorB

Before fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 0.     <- Offending result!
8.4.2-12 > 6.90.5-13 -> 1.     <- Side effect because GT uses LT

After fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 1.      <- Correct
8.4.2-12 > 6.90.5-13 -> 0.
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