@@ -63,32 +63,30 @@ 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[@]} ) ) ]})" ]; 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[@]} ))]}.0" ghe-host-check
74
- GHE_TEST_REMOTE_VERSION=" ${keys[$(( ${#keys[@]} - 1 ))]}.0" ghe-host-check
73
+ # Test most recent 2 versions
74
+ GHE_TEST_REMOTE_VERSION=" ${keys[-1]} .0" ghe-host-check
75
+ GHE_TEST_REMOTE_VERSION=" ${keys[-2]} .0" ghe-host-check
75
76
fi
76
77
else
77
78
# BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON
78
79
ix=0
79
- for i in " ${keys[@]} " ; do
80
+ for i in " ${keys[@]} " ; do
80
81
if [ " $i " == " $bu_major_minor " ]; then
81
82
break
82
83
fi
83
84
ix=$(( $ix + 1 ))
84
85
done
85
86
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
87
+ # Test previous 2 supported versions
88
+ GHE_TEST_REMOTE_VERSION=" ${keys[$(( $ix - 1 ))]} .0" ghe-host-check
90
89
GHE_TEST_REMOTE_VERSION=" ${keys[$(( $ix - 2 ))]} .0" ghe-host-check
91
-
92
90
fi
93
91
! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check
94
92
GHE_TEST_REMOTE_VERSION=$bu_version_major .$bu_version_minor .999 ghe-host-check
0 commit comments