Invert the priority order of the input and the rust-toolchain file

1. Not doing so would be a breaking change for users who have
a rust-toolchain file with a different version from what they
specify in the input.
2. Not doing so makes it overly complicated to install a specific
version.
Imagine you want to test your software against the version in the
rust-toolchain file and nightly as-well. Without this patch, users
will have the replace the content of the rust-toolchain file because
it is prioritized over the input.
It makes a lot more sense to prioritize the input over the file
because that one is easier changed.
This commit is contained in:
Thomas Eizinger 2020-01-14 10:16:10 +11:00
parent 9cf95ed753
commit 568a53bc9a
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
5 changed files with 38 additions and 14 deletions

View file

@ -28,15 +28,24 @@ export function toolchain_args(overrideFile: string): ToolchainOptions {
}
function determineToolchain(overrideFile: string): string {
if (existsSync(overrideFile)) {
debug(`using toolchain override from ${overrideFile}`);
const content = readFileSync(overrideFile, {
encoding: "utf-8",
flag: "r"
});
return content.trim();
} else {
debug(`toolchain override file ${overrideFile} does not exist, falling back to input variable`);
return input.getInput('toolchain', {required: true})
const toolchainInput = input.getInput('toolchain', {required: false});
if (toolchainInput) {
debug(`using toolchain from input: ${toolchainInput}`);
return toolchainInput
}
if (!existsSync(overrideFile)) {
throw new Error("toolchain input was not given and repository does not have a rust-toolchain file")
}
const rustToolchainFile = readFileSync(overrideFile, {
encoding: "utf-8",
flag: "r"
}).trim();
debug(`using toolchain from rust-toolchain file: ${rustToolchainFile}`);
return rustToolchainFile;
}