Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 921b0b6

Browse files
committed
Fix #248: resolve stack "2.1" to "2.1.3" rather than "2.11.1"
Fix taken from https://github.com/hspec/setup-haskell/blob/bdd4c910d94a07946cfdf9e6c3e7299a7e123705/src/resolve.ts#L25 as recommended by @sol in #248 (comment)
1 parent b53046b commit 921b0b6

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

setup/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ This list is replicated (hopefully correctly) below.
230230

231231
Versions specified by the inputs, e.g. `ghc-version`, are resolved against this list,
232232
by taking the first entry from the list if `latest` is requested,
233-
or the first entry that is a (string-)extension of the requested version otherwise.
234-
E.g., `8.10` will be resolved to `8.10.7`, and so will `8.10.`, `8.` and `8`
235-
(and incorrectly, [even `8.1`](github.com/haskell/actions/issues/248)).
233+
or the first entry that matches exactly,
234+
or otherwise the first entry that is a (string-)extension of the requested version extended by a `.`.
235+
E.g., `8.10` will be resolved to `8.10.7`, and so will `8`.
236236

237237
**GHC:**
238238

setup/__tests__/find-haskell.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ describe('haskell/actions/setup', () => {
9696
});
9797
});
9898

99-
it('Versions resolve as string prefix (resolving 8.1 to 8.10.x should be considered a bug)', () => {
99+
it('Versions resolve as version prefix', () => {
100100
const v = {ghc: '8.10.7', cabal: '2.4.1.0', stack: '2.1.3'};
101101
forAllOS(os => {
102102
const options = getOpts(def(os), os, {
103103
'enable-stack': 'true',
104104
'stack-version': '2.1',
105-
'ghc-version': '8.1',
105+
'ghc-version': '8.10',
106106
'cabal-version': '2'
107107
});
108108
forAllTools(t => expect(options[t].resolved).toBe(v[t]));

setup/dist/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/lib/opts.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/src/opts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ function resolve(
9797
const result =
9898
version === 'latest'
9999
? supported[0]
100-
: supported.find(v => v.startsWith(version)) ?? version;
100+
: supported.find(v => v === version) ??
101+
supported.find(v => v.startsWith(version + '.')) ??
102+
// Andreas, 2023-05-19, issue #248
103+
// Append "." so that eg stack "2.1" resolves to "2.1.3" and not "2.11.1".
104+
version;
101105
// Andreas 2022-12-29, issue #144: inform about resolution here where we can also output ${tool}.
102106
if (verbose === true && version !== result)
103107
core.info(`Resolved ${tool} ${version} to ${result}`);

0 commit comments

Comments
 (0)