|
|
|
@ -18,24 +18,31 @@ type checkOpts struct { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getCheckOpts(args []string) (*checkOpts, error) { |
|
|
|
|
sha, ok := env.Lookup("SOURCE_COMMIT", args) |
|
|
|
|
branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args) |
|
|
|
|
if !ok { |
|
|
|
|
return nil, cli.Exit(`missing environment variable "SOURCE_COMMIT"`, 1) |
|
|
|
|
return nil, cli.Exit("Unable to retrieve build source branch", 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url, ok := env.Lookup("DRONE_BUILD_LINK", args) |
|
|
|
|
var ( |
|
|
|
|
rgx = git.PRCheckRegexp() |
|
|
|
|
matches = rgx.FindStringSubmatch(branch) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
sha, ok := env.Lookup("SOURCE_COMMIT", args) |
|
|
|
|
if !ok { |
|
|
|
|
return nil, cli.Exit(`missing environment variable "DRONE_BUILD_LINK"`, 1) |
|
|
|
|
if matches == nil || len(matches) <= 1 { |
|
|
|
|
return nil, cli.Exit("Unable to retrieve source commit", 1) |
|
|
|
|
} |
|
|
|
|
sha = matches[2] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args) |
|
|
|
|
url, ok := env.Lookup("DRONE_BUILD_LINK", args) |
|
|
|
|
if !ok { |
|
|
|
|
return nil, cli.Exit("Unable to retrieve build source branch", 1) |
|
|
|
|
return nil, cli.Exit(`missing environment variable "DRONE_BUILD_LINK"`, 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prStr, ok := env.Lookup("OSS_PULL_REQUEST", args) |
|
|
|
|
if !ok { |
|
|
|
|
matches := git.PRCheckRegexp().FindStringSubmatch(branch) |
|
|
|
|
if matches == nil || len(matches) <= 1 { |
|
|
|
|
return nil, cli.Exit("Unable to retrieve PR number", 1) |
|
|
|
|
} |
|
|
|
|