Skip to content

Commit

Permalink
fix(github): handle reopened PR
Browse files Browse the repository at this point in the history
  • Loading branch information
corrieriluca committed Nov 5, 2023
1 parent 983ad07 commit 9d4db5a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/webhook/github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (g *Github) GetEvent(r *http.Request) (event.Event, error) {
ID: strconv.FormatInt(payload.PullRequest.Number, 10),
URL: event.NormalizeUrl(payload.Repository.HTMLURL),
Revision: payload.PullRequest.Head.Ref,
Action: payload.Action,
Action: getNormalizedAction(payload.Action),
Base: payload.PullRequest.Base.Ref,
Commit: payload.PullRequest.Head.Sha,
}
Expand All @@ -79,3 +79,14 @@ func (g *Github) GetEvent(r *http.Request) (event.Event, error) {
}
return e, nil
}

func getNormalizedAction(action string) string {
switch action {
case "opened", "reopened":
return event.PullRequestOpened
case "closed":
return event.PullRequestClosed
default:
return action
}
}

0 comments on commit 9d4db5a

Please sign in to comment.