mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
getting rid of string split and using the regex match
This commit is contained in:
parent
3e4b871991
commit
79dc866f43
1 changed files with 2 additions and 3 deletions
|
@ -260,14 +260,13 @@ func repoStatus(client *github.Client, r *model.Repo, b *model.Build, link strin
|
|||
}
|
||||
|
||||
func deploymentStatus(client *github.Client, r *model.Repo, b *model.Build, link string) error {
|
||||
// the deployment ID is only available in the the link to the build as the last element in the URL
|
||||
parts := strings.Split(b.Link, "/")
|
||||
matches := githubDeployRegex.FindStringSubmatch(b.Link)
|
||||
// if the deployment was not triggered from github, don't send a deployment status
|
||||
if len(matches) != 2 {
|
||||
return nil
|
||||
}
|
||||
id, _ := strconv.Atoi(parts[len(parts)-1])
|
||||
// the deployment ID is only available in the the link to the build as the last element in the URL
|
||||
id, _ := strconv.Atoi(matches[1])
|
||||
status := getStatus(b.Status)
|
||||
desc := getDesc(b.Status)
|
||||
data := github.DeploymentStatusRequest{
|
||||
|
|
Loading…
Reference in a new issue