Skip to content

Commit

Permalink
Compare VERSION with sort for rails-ex branching.
Browse files Browse the repository at this point in the history
Comparing the minor version when split with a dot will result
in 2.5 being bigger than 3.1, since in the comparison the 5 is
bigger than 1.
  • Loading branch information
jackorp authored and zmiklank committed Feb 27, 2024
1 parent c1de1db commit 04914ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ function test_from_dockerfile() {
# we can use the same Gemfile for RHEL 7 and newer
# as long as Ruby MAJOR.MINOR <= 3.1. Newer Ruby needs dependencies
# that are not compatible with RHEL 7.
ruby_major=$(echo "$VERSION" | cut -d'.' -f1)
ruby_minor=$(echo "$VERSION" | cut -d'.' -f2)

# Latest stable
rails_example_repo_branch="3.3"
if [[ "$ruby_major" -le 3 ]] && [[ "$ruby_minor" -le 1 ]]; then
if { echo "$VERSION"; echo "3.1"; } | sort --version-sort --check=quiet; then
# Ruby 3.1 and prior.
rails_example_repo_branch="master"
fi
Expand Down
5 changes: 2 additions & 3 deletions test/test-lib-ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ function rails_ex_branch() {
# we can use the same Gemfile for RHEL 7 and newer
# as long as Ruby MAJOR.MINOR <= 3.1. Newer Ruby needs dependencies
# that are not compatible with RHEL 7.
ruby_major=$(echo "$VERSION" | cut -d'.' -f1)
ruby_minor=$(echo "$VERSION" | cut -d'.' -f2)

# Latest stable
rails_example_repo_branch="3.3"
if [[ "$ruby_major" -le 3 ]] && [[ "$ruby_minor" -le 1 ]]; then
if { echo "$VERSION"; echo "3.1"; } | sort --version-sort --check=quiet; then
# Ruby 3.1 and prior.
rails_example_repo_branch="master"
fi
Expand Down

0 comments on commit 04914ba

Please sign in to comment.