summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-14 03:32:24 -0700
committerUnknwon <u@gogs.io>2016-08-14 03:32:24 -0700
commit3f7f4852efaaa56a0dada832dc652a1fc8869ae7 (patch)
treee3bb1769b2967dea560b2400abf830dc6cf70067 /routers/api
parent0f33b04c876593e592887450302774654fef2787 (diff)
downloadgitea-3f7f4852efaaa56a0dada832dc652a1fc8869ae7.tar.gz
gitea-3f7f4852efaaa56a0dada832dc652a1fc8869ae7.zip
#2246 fully support of webhooks for pull request
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/convert/convert.go25
-rw-r--r--routers/api/v1/repo/issue.go4
-rw-r--r--routers/api/v1/repo/issue_label.go4
3 files changed, 14 insertions, 19 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go
index cda1d86b45..c3ca9fd5d1 100644
--- a/routers/api/v1/convert/convert.go
+++ b/routers/api/v1/convert/convert.go
@@ -13,7 +13,6 @@ import (
api "github.com/gogits/go-gogs-client"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting"
)
@@ -48,16 +47,16 @@ func ToRepository(owner *models.User, repo *models.Repository, permission api.Pe
Description: repo.Description,
Private: repo.IsPrivate,
Fork: repo.IsFork,
- HtmlUrl: setting.AppUrl + owner.Name + "/" + repo.Name,
- CloneUrl: cl.HTTPS,
- SshUrl: cl.SSH,
+ 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,
+ Permissions: &permission,
}
}
@@ -183,7 +182,7 @@ func ToIssue(issue *models.Issue) *api.Issue {
ID: issue.ID,
Index: issue.Index,
State: issue.State(),
- Title: issue.Name,
+ Title: issue.Title,
Body: issue.Content,
User: ToUser(issue.Poster),
Labels: apiLabels,
@@ -194,15 +193,11 @@ func ToIssue(issue *models.Issue) *api.Issue {
Updated: issue.Updated,
}
if issue.IsPull {
- if err := issue.GetPullRequest(); err != nil {
- log.Error(4, "GetPullRequest", err)
- } else {
- apiIssue.PullRequest = &api.PullRequestMeta{
- HasMerged: issue.PullRequest.HasMerged,
- }
- if issue.PullRequest.HasMerged {
- apiIssue.PullRequest.Merged = &issue.PullRequest.Merged
- }
+ apiIssue.PullRequest = &api.PullRequestMeta{
+ HasMerged: issue.PullRequest.HasMerged,
+ }
+ if issue.PullRequest.HasMerged {
+ apiIssue.PullRequest.Merged = &issue.PullRequest.Merged
}
}
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index b105b6816c..90dc6e78e3 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -52,7 +52,7 @@ func GetIssue(ctx *context.APIContext) {
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
issue := &models.Issue{
RepoID: ctx.Repo.Repository.ID,
- Name: form.Title,
+ Title: form.Title,
PosterID: ctx.User.ID,
Poster: ctx.User,
Content: form.Body,
@@ -115,7 +115,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
}
if len(form.Title) > 0 {
- issue.Name = form.Title
+ issue.Title = form.Title
}
if form.Body != nil {
issue.Content = *form.Body
diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go
index e7cc63cde8..b471d4a08d 100644
--- a/routers/api/v1/repo/issue_label.go
+++ b/routers/api/v1/repo/issue_label.go
@@ -52,7 +52,7 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
return
}
- if err = issue.AddLabels(labels); err != nil {
+ if err = issue.AddLabels(ctx.User, labels); err != nil {
ctx.Error(500, "AddLabels", err)
return
}
@@ -160,7 +160,7 @@ func ClearIssueLabels(ctx *context.APIContext) {
return
}
- if err := issue.ClearLabels(); err != nil {
+ if err := issue.ClearLabels(ctx.User); err != nil {
ctx.Error(500, "ClearLabels", err)
return
}