@@ -63,32 +63,31 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions
63
63
# Use the modified releases string as needed
64
64
supported=$( echo " $releases_with_replacement " | jq -r ' select(."' ${bu_major_minor} ' ")' )
65
65
# shellcheck disable=SC2207 # Command required as alternatives fail
66
- keys=($( echo " $releases_with_replacement " | jq -r ' keys []' ) )
66
+ keys=($( echo " $releases_with_replacement " | jq -r ' . | keys_unsorted | sort_by( split(".") | map(tonumber) ) []' ) )
67
67
68
68
if [ -z " $supported " ]
69
69
then
70
70
# BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION
71
- if [ " $( version $bu_major_minor ) " -ge " $( version ${keys[$((${#keys[@]} - 2 ) ) ]})" ]; then
71
+ if [ " $( version $bu_major_minor ) " -ge " $( version ${keys[-1 ]} ) " ]; then
72
72
GHE_TEST_REMOTE_VERSION=" $bu_major_minor .0" ghe-host-check
73
- GHE_TEST_REMOTE_VERSION=" ${keys[$(( ${#keys[@]} - 2 ))]}.0" ghe-host-check
74
- GHE_TEST_REMOTE_VERSION=" ${keys[$(( ${#keys[@]} - 3 ))]}.0" ghe-host-check
73
+ # Test most recent version
74
+ # Don't test 2 versions back because it fails when we bump the version on
75
+ # master after branching for a feature release, before it's released
76
+ GHE_TEST_REMOTE_VERSION=" ${keys[-1]} .0" ghe-host-check
75
77
fi
76
78
else
77
79
# BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON
78
80
ix=0
79
- for i in " ${keys[@]} " ; do
81
+ for i in " ${keys[@]} " ; do
80
82
if [ " $i " == " $bu_major_minor " ]; then
81
83
break
82
84
fi
83
85
ix=$(( $ix + 1 ))
84
86
done
85
87
GHE_TEST_REMOTE_VERSION=" ${keys[$ix]} .0" ghe-host-check
86
- # sometimes when the latest.json is updated during a release this test gets broken.
87
- if [ " ${keys[$(( $ix - 1 ))]} " != " latest" ]; then
88
- GHE_TEST_REMOTE_VERSION=" ${keys[$(( $ix - 1 ))]} .0" ghe-host-check
89
- fi
88
+ # Test previous 2 supported versions
89
+ GHE_TEST_REMOTE_VERSION=" ${keys[$(( $ix - 1 ))]} .0" ghe-host-check
90
90
GHE_TEST_REMOTE_VERSION=" ${keys[$(( $ix - 2 ))]} .0" ghe-host-check
91
-
92
91
fi
93
92
! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check
94
93
GHE_TEST_REMOTE_VERSION=$bu_version_major .$bu_version_minor .999 ghe-host-check
0 commit comments