@@ -2019,6 +2019,9 @@ const core = __importStar(__webpack_require__(470));
2019
2019
const httpm = __importStar(__webpack_require__(539));
2020
2020
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
2021
2021
const parseVersion = (s) => {
2022
+ if (s == "latest" || s == "") {
2023
+ return null;
2024
+ }
2022
2025
const match = s.match(versionRe);
2023
2026
if (!match) {
2024
2027
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`);
@@ -2029,13 +2032,24 @@ const parseVersion = (s) => {
2029
2032
patch: match[3] === undefined ? null : parseInt(match[3]),
2030
2033
};
2031
2034
};
2032
- exports.stringifyVersion = (v) => `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
2035
+ exports.stringifyVersion = (v) => {
2036
+ if (v == null) {
2037
+ return "latest";
2038
+ }
2039
+ return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
2040
+ };
2033
2041
const minVersion = {
2034
2042
major: 1,
2035
2043
minor: 28,
2036
2044
patch: 3,
2037
2045
};
2038
2046
const isLessVersion = (a, b) => {
2047
+ if (a == null) {
2048
+ return true;
2049
+ }
2050
+ if (b == null) {
2051
+ return false;
2052
+ }
2039
2053
if (a.major != b.major) {
2040
2054
return a.major < b.major;
2041
2055
}
@@ -2044,8 +2058,11 @@ const isLessVersion = (a, b) => {
2044
2058
return a.minor < b.minor;
2045
2059
};
2046
2060
const getRequestedLintVersion = () => {
2047
- const requestedLintVersion = core.getInput(`version`, { required: true } );
2061
+ const requestedLintVersion = core.getInput(`version`);
2048
2062
const parsedRequestedLintVersion = parseVersion(requestedLintVersion);
2063
+ if (parsedRequestedLintVersion == null) {
2064
+ return null;
2065
+ }
2049
2066
if (parsedRequestedLintVersion.patch !== null) {
2050
2067
throw new Error(`requested golangci-lint version '${requestedLintVersion}' was specified with the patch version, need specify only minor version`);
2051
2068
}
@@ -2076,12 +2093,12 @@ function findLintVersion() {
2076
2093
return __awaiter(this, void 0, void 0, function* () {
2077
2094
core.info(`Finding needed golangci-lint version...`);
2078
2095
const startedAt = Date.now();
2079
- const reqLintVersion = getRequestedLintVersion();
2080
2096
const config = yield getConfig();
2081
2097
if (!config.MinorVersionToConfig) {
2082
2098
core.warning(JSON.stringify(config));
2083
2099
throw new Error(`invalid config: no MinorVersionToConfig field`);
2084
2100
}
2101
+ const reqLintVersion = getRequestedLintVersion();
2085
2102
const versionConfig = config.MinorVersionToConfig[exports.stringifyVersion(reqLintVersion)];
2086
2103
if (!versionConfig) {
2087
2104
throw new Error(`requested golangci-lint version '${exports.stringifyVersion(reqLintVersion)}' doesn't exist`);
0 commit comments