summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/convert
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-14 04:17:26 -0700
committerUnknwon <u@gogs.io>2016-08-14 04:17:26 -0700
commitdccb0c15b996ac4dc0307cbfed140ce1558d7e3c (patch)
tree97593eae3a1023296c2c03258e6bc4ae4c02b6bf /routers/api/v1/convert
parent3f7f4852efaaa56a0dada832dc652a1fc8869ae7 (diff)
downloadgitea-dccb0c15b996ac4dc0307cbfed140ce1558d7e3c.tar.gz
gitea-dccb0c15b996ac4dc0307cbfed140ce1558d7e3c.zip
Replace convert.To with APIFormat calls
Diffstat (limited to 'routers/api/v1/convert')
-rw-r--r--routers/api/v1/convert/convert.go103
1 files changed, 2 insertions, 101 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go
index c3ca9fd5d1..fcadb51fd4 100644
--- a/routers/api/v1/convert/convert.go
+++ b/routers/api/v1/convert/convert.go
@@ -13,23 +13,8 @@ import (
api "github.com/gogits/go-gogs-client"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/setting"
)
-func ToUser(u *models.User) *api.User {
- if u == nil {
- return nil
- }
-
- return &api.User{
- ID: u.ID,
- UserName: u.Name,
- FullName: u.FullName,
- Email: u.Email,
- AvatarUrl: u.AvatarLink(),
- }
-}
-
func ToEmail(email *models.EmailAddress) *api.Email {
return &api.Email{
Email: email.Email,
@@ -38,28 +23,6 @@ func ToEmail(email *models.EmailAddress) *api.Email {
}
}
-func ToRepository(owner *models.User, repo *models.Repository, permission api.Permission) *api.Repository {
- cl := repo.CloneLink()
- return &api.Repository{
- ID: repo.ID,
- Owner: ToUser(owner),
- FullName: owner.Name + "/" + repo.Name,
- Description: repo.Description,
- Private: repo.IsPrivate,
- Fork: repo.IsFork,
- HTMLURL: setting.AppUrl + owner.Name + "/" + repo.Name,
- CloneURL: cl.HTTPS,
- SSHURL: cl.SSH,
- OpenIssues: repo.NumOpenIssues,
- Stars: repo.NumStars,
- Forks: repo.NumForks,
- Watchers: repo.NumWatches,
- Created: repo.Created,
- Updated: repo.Updated,
- Permissions: &permission,
- }
-}
-
func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
return &api.Branch{
Name: b.Name,
@@ -82,12 +45,12 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
ID: c.ID.String(),
Message: c.Message(),
URL: "Not implemented",
- Author: &api.PayloadAuthor{
+ Author: &api.PayloadUser{
Name: c.Author.Name,
Email: c.Author.Email,
UserName: authorUsername,
},
- Committer: &api.PayloadCommitter{
+ Committer: &api.PayloadUser{
Name: c.Committer.Name,
Email: c.Committer.Email,
UserName: committerUsername,
@@ -142,68 +105,6 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
}
}
-func ToLabel(label *models.Label) *api.Label {
- return &api.Label{
- ID: label.ID,
- Name: label.Name,
- Color: label.Color,
- }
-}
-
-func ToMilestone(milestone *models.Milestone) *api.Milestone {
- if milestone == nil {
- return nil
- }
-
- apiMilestone := &api.Milestone{
- ID: milestone.ID,
- State: milestone.State(),
- Title: milestone.Name,
- Description: milestone.Content,
- OpenIssues: milestone.NumOpenIssues,
- ClosedIssues: milestone.NumClosedIssues,
- }
- if milestone.IsClosed {
- apiMilestone.Closed = &milestone.ClosedDate
- }
- if milestone.Deadline.Year() < 9999 {
- apiMilestone.Deadline = &milestone.Deadline
- }
- return apiMilestone
-}
-
-func ToIssue(issue *models.Issue) *api.Issue {
- apiLabels := make([]*api.Label, len(issue.Labels))
- for i := range issue.Labels {
- apiLabels[i] = ToLabel(issue.Labels[i])
- }
-
- apiIssue := &api.Issue{
- ID: issue.ID,
- Index: issue.Index,
- State: issue.State(),
- Title: issue.Title,
- Body: issue.Content,
- User: ToUser(issue.Poster),
- Labels: apiLabels,
- Assignee: ToUser(issue.Assignee),
- Milestone: ToMilestone(issue.Milestone),
- Comments: issue.NumComments,
- Created: issue.Created,
- Updated: issue.Updated,
- }
- if issue.IsPull {
- apiIssue.PullRequest = &api.PullRequestMeta{
- HasMerged: issue.PullRequest.HasMerged,
- }
- if issue.PullRequest.HasMerged {
- apiIssue.PullRequest.Merged = &issue.PullRequest.Merged
- }
- }
-
- return apiIssue
-}
-
func ToOrganization(org *models.User) *api.Organization {
return &api.Organization{
ID: org.ID,