feat: add convertCorePullRequest

This commit is contained in:
Derrick Hammer 2024-02-12 16:42:00 -05:00
parent e33587b406
commit c345f1c72a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 41 additions and 2 deletions

View File

@ -212,7 +212,46 @@ func convertCoreRepo(repo *structs.Repository) *github.Repository {
}
}
func convertPullRequest(request *structs.PullRequest) *github.PullRequest {
func convertPullRequest(request *gitea.PullRequest) *github.PullRequest {
if request == nil {
return &github.PullRequest{}
}
pr := &github.PullRequest{
ID: int64Ptr(request.ID),
Number: intPtr(int(request.Index)),
State: stringPtr(string(request.State)),
Title: stringPtr(request.Title),
Body: stringPtr(request.Body),
CreatedAt: timePtr(*request.Created),
UpdatedAt: timePtr(*request.Updated),
ClosedAt: timePtrIfNotNil(request.Closed),
MergedAt: timePtrIfNotNil(request.Merged),
Merged: boolPtr(request.HasMerged),
Mergeable: boolPtr(request.Mergeable),
MergeCommitSHA: request.MergedCommitID,
URL: stringPtr(request.URL),
HTMLURL: stringPtr(request.HTMLURL),
DiffURL: stringPtr(request.DiffURL),
PatchURL: stringPtr(request.PatchURL),
Comments: intPtr(request.Comments),
Assignee: convertUser(request.Assignee),
Assignees: convertUsers(request.Assignees),
Milestone: convertMilestone(request.Milestone),
Labels: convertLabels(request.Labels),
}
// Convert PR branch info
if request.Head != nil {
pr.Head = convertPRBranch(request.Head)
}
if request.Base != nil {
pr.Base = convertPRBranch(request.Base)
}
return pr
}
func convertCorePullRequest(request *structs.PullRequest) *github.PullRequest {
if request == nil {
return &github.PullRequest{}
}

View File

@ -16,7 +16,7 @@ func convertPullRequestEvent(event *structs.PullRequestPayload) *github.PullRequ
return &github.PullRequestEvent{
Action: stringPtr(translatePrAction(event.Action, false)),
PullRequest: convertPullRequest(event.PullRequest),
PullRequest: convertCorePullRequest(event.PullRequest),
Repo: convertCoreRepo(event.Repository),
Assignee: convertCoreUser(event.PullRequest.Assignee),
Number: intPtr(int(event.Index)),