gitea-github-proxy/api/convert_event.go

29 lines
1.0 KiB
Go
Raw Normal View History

package api
import (
"code.gitea.io/gitea/modules/structs"
"github.com/google/go-github/v59/github"
)
func convertPullRequestEvent(event *structs.PullRequestPayload) *github.PullRequestEvent {
if len(event.PullRequest.RequestedReviewers) == 0 {
event.PullRequest.RequestedReviewers = append(event.PullRequest.RequestedReviewers, nil)
}
if len(event.PullRequest.Labels) == 0 {
event.PullRequest.Labels = append(event.PullRequest.Labels, nil)
}
return &github.PullRequestEvent{
Action: stringPtr(translatePrAction(event.Action, false)),
2024-02-12 21:42:00 +00:00
PullRequest: convertCorePullRequest(event.PullRequest),
Repo: convertCoreRepo(event.Repository),
Assignee: convertCoreUser(event.PullRequest.Assignee),
Number: intPtr(int(event.Index)),
Changes: convertChanges(event.Changes),
RequestedReviewer: convertCoreUser(event.PullRequest.RequestedReviewers[0]),
Sender: convertCoreUser(event.Sender),
Label: convertCoreLabel(event.PullRequest.Labels[0]),
}
}