File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
import * as core from "@actions/core"
2
2
import * as httpm from "@actions/http-client"
3
+ import * as fs from 'fs'
3
4
4
5
// TODO: make a class
5
6
export type Version = {
@@ -9,6 +10,7 @@ export type Version = {
9
10
} | null
10
11
11
12
const versionRe = / ^ v ( \d + ) \. ( \d + ) (?: \. ( \d + ) ) ? $ /
13
+ const modVersionRe = / g i t h u b .c o m \/ g o l a n g c i \/ g o l a n g c i - l i n t \s v ( .+ ) /
12
14
13
15
const parseVersion = ( s : string ) : Version => {
14
16
if ( s == "latest" || s == "" ) {
@@ -56,7 +58,16 @@ const isLessVersion = (a: Version, b: Version): boolean => {
56
58
}
57
59
58
60
const getRequestedLintVersion = ( ) : Version => {
59
- const requestedLintVersion = core . getInput ( `version` )
61
+ let requestedLintVersion = core . getInput ( `version` )
62
+
63
+ if ( requestedLintVersion == "" ) {
64
+ const content = fs . readFileSync ( 'go.mod' , 'utf-8' )
65
+ const match = content . match ( modVersionRe )
66
+ if ( match ) {
67
+ requestedLintVersion = match [ 0 ]
68
+ }
69
+ }
70
+
60
71
const parsedRequestedLintVersion = parseVersion ( requestedLintVersion )
61
72
if ( parsedRequestedLintVersion == null ) {
62
73
return null
You can’t perform that action at this time.
0 commit comments