@@ -2019,6 +2019,9 @@ const core = __importStar(__webpack_require__(470));
20192019const httpm = __importStar(__webpack_require__(539));
20202020const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
20212021const parseVersion = (s) => {
2022+ if (s == "latest" || s == "") {
2023+ return null;
2024+ }
20222025 const match = s.match(versionRe);
20232026 if (!match) {
20242027 throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`);
@@ -2029,13 +2032,24 @@ const parseVersion = (s) => {
20292032 patch: match[3] === undefined ? null : parseInt(match[3]),
20302033 };
20312034};
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+ };
20332041const minVersion = {
20342042 major: 1,
20352043 minor: 28,
20362044 patch: 3,
20372045};
20382046const isLessVersion = (a, b) => {
2047+ if (a == null) {
2048+ return true;
2049+ }
2050+ if (b == null) {
2051+ return false;
2052+ }
20392053 if (a.major != b.major) {
20402054 return a.major < b.major;
20412055 }
@@ -2044,8 +2058,11 @@ const isLessVersion = (a, b) => {
20442058 return a.minor < b.minor;
20452059};
20462060const getRequestedLintVersion = () => {
2047- const requestedLintVersion = core.getInput(`version`, { required: true } );
2061+ const requestedLintVersion = core.getInput(`version`);
20482062 const parsedRequestedLintVersion = parseVersion(requestedLintVersion);
2063+ if (parsedRequestedLintVersion == null) {
2064+ return null;
2065+ }
20492066 if (parsedRequestedLintVersion.patch !== null) {
20502067 throw new Error(`requested golangci-lint version '${requestedLintVersion}' was specified with the patch version, need specify only minor version`);
20512068 }
@@ -2076,12 +2093,12 @@ function findLintVersion() {
20762093 return __awaiter(this, void 0, void 0, function* () {
20772094 core.info(`Finding needed golangci-lint version...`);
20782095 const startedAt = Date.now();
2079- const reqLintVersion = getRequestedLintVersion();
20802096 const config = yield getConfig();
20812097 if (!config.MinorVersionToConfig) {
20822098 core.warning(JSON.stringify(config));
20832099 throw new Error(`invalid config: no MinorVersionToConfig field`);
20842100 }
2101+ const reqLintVersion = getRequestedLintVersion();
20852102 const versionConfig = config.MinorVersionToConfig[exports.stringifyVersion(reqLintVersion)];
20862103 if (!versionConfig) {
20872104 throw new Error(`requested golangci-lint version '${exports.stringifyVersion(reqLintVersion)}' doesn't exist`);
0 commit comments