diff --git a/api/convert.go b/api/convert.go index ee64ae4..a6a35e2 100644 --- a/api/convert.go +++ b/api/convert.go @@ -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{} } diff --git a/api/convert_event.go b/api/convert_event.go index b9943f9..a481066 100644 --- a/api/convert_event.go +++ b/api/convert_event.go @@ -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)),