Skip to content

Commit 51cce09

Browse files
committed
Fix latest-allowed version matching
1 parent 39d8c27 commit 51cce09

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libexec/tfenv-resolve-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then
142142
;;
143143
'~>'*)
144144
version_without_rightmost="${version_num%.*}";
145-
version_requested="latest:^${version_without_rightmost}";
145+
version_requested="latest:^${version_without_rightmost}\.";
146146
;;
147147
*)
148148
log 'error' "Unsupported version spec: '${version_spec}', only >, >=, <=, and ~> are supported.";

test/test_use_latestallowed.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ echo "terraform {
6363
tfenv install latest-allowed;
6464
tfenv use latest-allowed;
6565
check_active_version 1.1.9;
66-
) || error_and_proceed 'Latest allowed version does not match';
66+
) || error_and_proceed 'Latest allowed version does not match. Requested: "~> 1.1.0", Expected: 1.1.9';
6767

6868
cleanup || log 'error' 'Cleanup failed?!';
6969

@@ -78,7 +78,7 @@ echo "terraform {
7878
tfenv install latest-allowed;
7979
tfenv use latest-allowed;
8080
check_active_version 0.13.0-rc1;
81-
) || error_and_proceed 'Latest allowed tagged-version does not match';
81+
) || error_and_proceed 'Latest allowed tagged-version does not match. Requested: "<=0.13.0-rc1", Expected: 0.13.0-rc1';
8282

8383
cleanup || log 'error' 'Cleanup failed?!';
8484

@@ -93,7 +93,7 @@ echo "terraform {
9393
tfenv install latest-allowed;
9494
tfenv use latest-allowed;
9595
check_active_version 0.15.5;
96-
) || error_and_proceed 'Latest allowed incomplete-version does not match';
96+
) || error_and_proceed 'Latest allowed incomplete-version does not match. Requested: "~> 0.12", Expected: 0.15.5';
9797

9898
cleanup || log 'error' 'Cleanup failed?!';
9999

@@ -108,7 +108,7 @@ echo 'latest-allowed' > .terraform-version;
108108
(
109109
TFENV_AUTO_INSTALL=true terraform version;
110110
check_active_version 1.0.11;
111-
) || error_and_proceed 'Latest allowed auto-installed version does not match';
111+
) || error_and_proceed 'Latest allowed auto-installed version does not match. Requested: "~> 1.0.0", Expected: 1.0.11';
112112

113113
cleanup || log 'error' 'Cleanup failed?!';
114114

@@ -124,7 +124,7 @@ echo 'latest-allowed' > chdir-dir/.terraform-version
124124
(
125125
TFENV_AUTO_INSTALL=true terraform -chdir=chdir-dir version;
126126
check_active_version 0.14.11 chdir-dir;
127-
) || error_and_proceed 'Latest allowed version from -chdir does not match';
127+
) || error_and_proceed 'Latest allowed version from -chdir does not match. Requested: "~> 0.14.3", Expected: 0.14.11';
128128

129129
cleanup || log 'error' 'Cleanup failed?!';
130130

0 commit comments

Comments
 (0)