refactor: use sdk version of structs where possible to avoid conflicts

This commit is contained in:
Derrick Hammer 2024-02-12 01:46:41 -05:00
parent aa52bd2e59
commit c607400951
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 11 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package api
import ( import (
"code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/structs"
gitea "code.gitea.io/sdk/gitea"
"fmt" "fmt"
"github.com/google/go-github/v59/github" "github.com/google/go-github/v59/github"
"time" "time"
@ -39,7 +40,7 @@ func timePtrIfNotNil(t *time.Time) *github.Timestamp {
return timePtr(*t) return timePtr(*t)
} }
func convertUser(user *structs.User) *github.User { func convertUser(user *gitea.User) *github.User {
if user == nil { if user == nil {
return &github.User{} return &github.User{}
} }
@ -49,7 +50,7 @@ func convertUser(user *structs.User) *github.User {
} }
} }
func convertUsers(users []*structs.User) []*github.User { func convertUsers(users []*gitea.User) []*github.User {
var ghUsers []*github.User var ghUsers []*github.User
for _, user := range users { for _, user := range users {
ghUsers = append(ghUsers, convertUser(user)) ghUsers = append(ghUsers, convertUser(user))
@ -57,7 +58,7 @@ func convertUsers(users []*structs.User) []*github.User {
return ghUsers return ghUsers
} }
func convertMilestone(milestone *structs.Milestone) *github.Milestone { func convertMilestone(milestone *gitea.Milestone) *github.Milestone {
if milestone == nil { if milestone == nil {
return &github.Milestone{} return &github.Milestone{}
} }
@ -66,7 +67,7 @@ func convertMilestone(milestone *structs.Milestone) *github.Milestone {
} }
} }
func convertLabels(labels []*structs.Label) []*github.Label { func convertLabels(labels []*gitea.Label) []*github.Label {
if labels == nil { if labels == nil {
return make([]*github.Label, 0) return make([]*github.Label, 0)
} }
@ -82,7 +83,7 @@ func convertLabels(labels []*structs.Label) []*github.Label {
return ghLabels return ghLabels
} }
func convertPRBranch(branch *structs.PRBranchInfo) *github.PullRequestBranch { func convertPRBranch(branch *gitea.PRBranchInfo) *github.PullRequestBranch {
if branch == nil { if branch == nil {
return &github.PullRequestBranch{} return &github.PullRequestBranch{}
} }
@ -94,7 +95,7 @@ func convertPRBranch(branch *structs.PRBranchInfo) *github.PullRequestBranch {
} }
} }
func convertRepo(repo *structs.Repository) *github.Repository { func convertRepo(repo *gitea.Repository) *github.Repository {
if repo == nil { if repo == nil {
return &github.Repository{} return &github.Repository{}
} }
@ -125,7 +126,7 @@ func convertRepo(repo *structs.Repository) *github.Repository {
} }
} }
func convertPullRequest(request *structs.PullRequest) *github.PullRequest { func convertPullRequest(request *gitea.PullRequest) *github.PullRequest {
if request == nil { if request == nil {
return &github.PullRequest{} return &github.PullRequest{}
} }
@ -183,7 +184,7 @@ func convertChanges(changes *structs.ChangesPayload) *github.EditChange {
} }
} }
func convertLabel(label *structs.Label) *github.Label { func convertLabel(label *gitea.Label) *github.Label {
if label == nil { if label == nil {
return &github.Label{} return &github.Label{}
} }
@ -196,7 +197,7 @@ func convertLabel(label *structs.Label) *github.Label {
} }
} }
func convertCommitFile(file *structs.ChangedFile) *github.CommitFile { func convertCommitFile(file *gitea.ChangedFile) *github.CommitFile {
if file == nil { if file == nil {
return &github.CommitFile{} return &github.CommitFile{}
} }

View File

@ -1,7 +1,6 @@
package api package api
import ( import (
structs "code.gitea.io/gitea/modules/structs"
gitea "code.gitea.io/sdk/gitea" gitea "code.gitea.io/sdk/gitea"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -53,8 +52,7 @@ func (r restApi) handlerGetPullRequestFiles(w http.ResponseWriter, request *http
githubFiles := make([]*github.CommitFile, len(files)) githubFiles := make([]*github.CommitFile, len(files))
for i, file := range files { for i, file := range files {
f := structs.ChangedFile(*file) githubFiles[i] = convertCommitFile(file)
githubFiles[i] = convertCommitFile(&f)
} }
r.sendPagingHeaders(w, r2) r.sendPagingHeaders(w, r2)