mirror of https://github.com/gogs/gogs.git
parent
bab448681d
commit
c93731339f
|
@ -760,10 +760,12 @@ settings.event_delete = Delete
|
||||||
settings.event_delete_desc = Branch or tag deleted
|
settings.event_delete_desc = Branch or tag deleted
|
||||||
settings.event_fork = Fork
|
settings.event_fork = Fork
|
||||||
settings.event_fork_desc = Repository forked
|
settings.event_fork_desc = Repository forked
|
||||||
settings.event_pull_request = Pull Request
|
|
||||||
settings.event_pull_request_desc = Pull request opened, closed, reopened, edited, assigned, unassigned, label updated, label cleared, or synchronized.
|
|
||||||
settings.event_push = Push
|
settings.event_push = Push
|
||||||
settings.event_push_desc = Git push to a repository
|
settings.event_push_desc = Git push to a repository
|
||||||
|
settings.event_issue = Issues
|
||||||
|
settings.event_issue_desc = Issue opened, closed, reopened, edited, assigned, unassigned, label updated, label cleared, milestoned, or demilestoned.
|
||||||
|
settings.event_pull_request = Pull Request
|
||||||
|
settings.event_pull_request_desc = Pull request opened, closed, reopened, edited, assigned, unassigned, label updated, label cleared, milestoned, demilestoned, or synchronized.
|
||||||
settings.active = Active
|
settings.active = Active
|
||||||
settings.active_helper = Details regarding the event which triggered the hook will be delivered as well.
|
settings.active_helper = Details regarding the event which triggered the hook will be delivered as well.
|
||||||
settings.add_hook_success = New webhook has been added.
|
settings.add_hook_success = New webhook has been added.
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.10.10.0308"
|
const APP_VER = "0.10.11.0308"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|
116
models/issue.go
116
models/issue.go
|
@ -230,7 +230,7 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
err = issue.PullRequest.LoadIssue()
|
err = issue.PullRequest.LoadIssue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "LoadIssue: %v", err)
|
log.Error(2, "LoadIssue: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
||||||
|
@ -240,9 +240,17 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
|
||||||
Repository: issue.Repo.APIFormat(nil),
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: api.HOOK_ISSUE_LABEL_UPDATED,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
} else {
|
||||||
go HookQueue.Add(issue.RepoID)
|
go HookQueue.Add(issue.RepoID)
|
||||||
}
|
}
|
||||||
|
@ -334,7 +342,7 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
err = issue.PullRequest.LoadIssue()
|
err = issue.PullRequest.LoadIssue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "LoadIssue: %v", err)
|
log.Error(2, "LoadIssue: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
||||||
|
@ -344,9 +352,17 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
|
||||||
Repository: issue.Repo.APIFormat(nil),
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: api.HOOK_ISSUE_LABEL_CLEARED,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
} else {
|
||||||
go HookQueue.Add(issue.RepoID)
|
go HookQueue.Add(issue.RepoID)
|
||||||
}
|
}
|
||||||
|
@ -470,9 +486,22 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
|
||||||
apiPullRequest.Action = api.HOOK_ISSUE_REOPENED
|
apiPullRequest.Action = api.HOOK_ISSUE_REOPENED
|
||||||
}
|
}
|
||||||
err = PrepareWebhooks(repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
|
err = PrepareWebhooks(repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
|
||||||
|
} else {
|
||||||
|
apiIssues := &api.IssuesPayload{
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
}
|
||||||
|
if isClosed {
|
||||||
|
apiIssues.Action = api.HOOK_ISSUE_CLOSED
|
||||||
|
} else {
|
||||||
|
apiIssues.Action = api.HOOK_ISSUE_REOPENED
|
||||||
|
}
|
||||||
|
err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, apiIssues)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
|
log.Error(2, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
|
||||||
} else {
|
} else {
|
||||||
go HookQueue.Add(repo.ID)
|
go HookQueue.Add(repo.ID)
|
||||||
}
|
}
|
||||||
|
@ -490,20 +519,33 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) {
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
issue.PullRequest.Issue = issue
|
issue.PullRequest.Issue = issue
|
||||||
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
||||||
Action: api.HOOK_ISSUE_EDITED,
|
Action: api.HOOK_ISSUE_EDITED,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
Title: &api.ChangesFromPayload{
|
Title: &api.ChangesFromPayload{
|
||||||
From: oldTitle,
|
From: oldTitle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
Repository: issue.Repo.APIFormat(nil),
|
Sender: doer.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
})
|
||||||
|
} else {
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: api.HOOK_ISSUE_EDITED,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Changes: &api.ChangesPayload{
|
||||||
|
Title: &api.ChangesFromPayload{
|
||||||
|
From: oldTitle,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
} else {
|
||||||
go HookQueue.Add(issue.RepoID)
|
go HookQueue.Add(issue.RepoID)
|
||||||
}
|
}
|
||||||
|
@ -521,20 +563,33 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
issue.PullRequest.Issue = issue
|
issue.PullRequest.Issue = issue
|
||||||
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
||||||
Action: api.HOOK_ISSUE_EDITED,
|
Action: api.HOOK_ISSUE_EDITED,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
Body: &api.ChangesFromPayload{
|
Body: &api.ChangesFromPayload{
|
||||||
From: oldContent,
|
From: oldContent,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
Repository: issue.Repo.APIFormat(nil),
|
Sender: doer.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
})
|
||||||
|
} else {
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: api.HOOK_ISSUE_EDITED,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Changes: &api.ChangesPayload{
|
||||||
|
Body: &api.ChangesFromPayload{
|
||||||
|
From: oldContent,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
} else {
|
||||||
go HookQueue.Add(issue.RepoID)
|
go HookQueue.Add(issue.RepoID)
|
||||||
}
|
}
|
||||||
|
@ -570,6 +625,19 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
|
||||||
apiPullRequest.Action = api.HOOK_ISSUE_ASSIGNED
|
apiPullRequest.Action = api.HOOK_ISSUE_ASSIGNED
|
||||||
}
|
}
|
||||||
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
|
||||||
|
} else {
|
||||||
|
apiIssues := &api.IssuesPayload{
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
}
|
||||||
|
if isRemoveAssignee {
|
||||||
|
apiIssues.Action = api.HOOK_ISSUE_UNASSIGNED
|
||||||
|
} else {
|
||||||
|
apiIssues.Action = api.HOOK_ISSUE_ASSIGNED
|
||||||
|
}
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, apiIssues)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
|
log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
|
||||||
|
@ -715,10 +783,20 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
|
||||||
RepoName: repo.Name,
|
RepoName: repo.Name,
|
||||||
IsPrivate: repo.IsPrivate,
|
IsPrivate: repo.IsPrivate,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "NotifyWatchers: %v", err)
|
log.Error(2, "NotifyWatchers: %v", err)
|
||||||
}
|
}
|
||||||
if err = issue.MailParticipants(); err != nil {
|
if err = issue.MailParticipants(); err != nil {
|
||||||
log.Error(4, "MailParticipants: %v", err)
|
log.Error(2, "MailParticipants: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: api.HOOK_ISSUE_OPENED,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: repo.APIFormat(nil),
|
||||||
|
Sender: issue.Poster.APIFormat(),
|
||||||
|
}); err != nil {
|
||||||
|
log.Error(2, "PrepareWebhooks: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -240,7 +240,13 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
|
||||||
if issue.IsClosed {
|
if issue.IsClosed {
|
||||||
label.NumClosedIssues++
|
label.NumClosedIssues++
|
||||||
}
|
}
|
||||||
return updateLabel(e, label)
|
|
||||||
|
if err = updateLabel(e, label); err != nil {
|
||||||
|
return fmt.Errorf("updateLabel: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
issue.Labels = append(issue.Labels, label)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIssueLabel creates a new issue-label relation.
|
// NewIssueLabel creates a new issue-label relation.
|
||||||
|
@ -313,7 +319,17 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
|
||||||
if issue.IsClosed {
|
if issue.IsClosed {
|
||||||
label.NumClosedIssues--
|
label.NumClosedIssues--
|
||||||
}
|
}
|
||||||
return updateLabel(e, label)
|
if err = updateLabel(e, label); err != nil {
|
||||||
|
return fmt.Errorf("updateLabel: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range issue.Labels {
|
||||||
|
if issue.Labels[i].ID == label.ID {
|
||||||
|
issue.Labels = append(issue.Labels[:i], issue.Labels[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteIssueLabel deletes issue-label relation.
|
// DeleteIssueLabel deletes issue-label relation.
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
@ -272,6 +274,8 @@ func changeMilestoneAssign(e *xorm.Session, issue *Issue, oldMilestoneID int64)
|
||||||
} else if _, err = e.Exec("UPDATE `issue_user` SET milestone_id = 0 WHERE issue_id = ?", issue.ID); err != nil {
|
} else if _, err = e.Exec("UPDATE `issue_user` SET milestone_id = 0 WHERE issue_id = ?", issue.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue.Milestone = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if issue.MilestoneID > 0 {
|
if issue.MilestoneID > 0 {
|
||||||
|
@ -290,13 +294,15 @@ func changeMilestoneAssign(e *xorm.Session, issue *Issue, oldMilestoneID int64)
|
||||||
} else if _, err = e.Exec("UPDATE `issue_user` SET milestone_id = ? WHERE issue_id = ?", m.ID, issue.ID); err != nil {
|
} else if _, err = e.Exec("UPDATE `issue_user` SET milestone_id = ? WHERE issue_id = ?", m.ID, issue.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue.Milestone = m
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateIssue(e, issue)
|
return updateIssue(e, issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeMilestoneAssign changes assignment of milestone for issue.
|
// ChangeMilestoneAssign changes assignment of milestone for issue.
|
||||||
func ChangeMilestoneAssign(issue *Issue, oldMilestoneID int64) (err error) {
|
func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err error) {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
if err = sess.Begin(); err != nil {
|
if err = sess.Begin(); err != nil {
|
||||||
|
@ -306,7 +312,47 @@ func ChangeMilestoneAssign(issue *Issue, oldMilestoneID int64) (err error) {
|
||||||
if err = changeMilestoneAssign(sess, issue, oldMilestoneID); err != nil {
|
if err = changeMilestoneAssign(sess, issue, oldMilestoneID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return sess.Commit()
|
|
||||||
|
if err = sess.Commit(); err != nil {
|
||||||
|
return fmt.Errorf("Commit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var hookAction api.HookIssueAction
|
||||||
|
if issue.MilestoneID > 0 {
|
||||||
|
hookAction = api.HOOK_ISSUE_MILESTONED
|
||||||
|
} else {
|
||||||
|
hookAction = api.HOOK_ISSUE_DEMILESTONED
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.IsPull {
|
||||||
|
err = issue.PullRequest.LoadIssue()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(2, "LoadIssue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
||||||
|
Action: hookAction,
|
||||||
|
Index: issue.Index,
|
||||||
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
|
||||||
|
Action: hookAction,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(nil),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
|
} else {
|
||||||
|
go HookQueue.Add(issue.RepoID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMilestoneOfRepoByID deletes a milestone from a repository.
|
// DeleteMilestoneOfRepoByID deletes a milestone from a repository.
|
||||||
|
|
|
@ -437,9 +437,10 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
|
||||||
RepoName: repo.Name,
|
RepoName: repo.Name,
|
||||||
IsPrivate: repo.IsPrivate,
|
IsPrivate: repo.IsPrivate,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "NotifyWatchers: %v", err)
|
log.Error(2, "NotifyWatchers: %v", err)
|
||||||
} else if err = pull.MailParticipants(); err != nil {
|
}
|
||||||
log.Error(4, "MailParticipants: %v", err)
|
if err = pull.MailParticipants(); err != nil {
|
||||||
|
log.Error(2, "MailParticipants: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pr.Issue = pull
|
pr.Issue = pull
|
||||||
|
@ -451,7 +452,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
|
||||||
Repository: repo.APIFormat(nil),
|
Repository: repo.APIFormat(nil),
|
||||||
Sender: pull.Poster.APIFormat(),
|
Sender: pull.Poster.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "PrepareWebhooks: %v", err)
|
log.Error(2, "PrepareWebhooks: %v", err)
|
||||||
}
|
}
|
||||||
go HookQueue.Add(repo.ID)
|
go HookQueue.Add(repo.ID)
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ type HookEvents struct {
|
||||||
Delete bool `json:"delete"`
|
Delete bool `json:"delete"`
|
||||||
Fork bool `json:"fork"`
|
Fork bool `json:"fork"`
|
||||||
Push bool `json:"push"`
|
Push bool `json:"push"`
|
||||||
|
Issues bool `json:"issues"`
|
||||||
PullRequest bool `json:"pull_request"`
|
PullRequest bool `json:"pull_request"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +177,12 @@ func (w *Webhook) HasPushEvent() bool {
|
||||||
(w.ChooseEvents && w.HookEvents.Push)
|
(w.ChooseEvents && w.HookEvents.Push)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasIssuesEvent returns true if hook enabled issues event.
|
||||||
|
func (w *Webhook) HasIssuesEvent() bool {
|
||||||
|
return w.SendEverything ||
|
||||||
|
(w.ChooseEvents && w.HookEvents.Issues)
|
||||||
|
}
|
||||||
|
|
||||||
// HasPullRequestEvent returns true if hook enabled pull request event.
|
// HasPullRequestEvent returns true if hook enabled pull request event.
|
||||||
func (w *Webhook) HasPullRequestEvent() bool {
|
func (w *Webhook) HasPullRequestEvent() bool {
|
||||||
return w.SendEverything ||
|
return w.SendEverything ||
|
||||||
|
@ -360,6 +367,7 @@ const (
|
||||||
HOOK_EVENT_DELETE HookEventType = "delete"
|
HOOK_EVENT_DELETE HookEventType = "delete"
|
||||||
HOOK_EVENT_FORK HookEventType = "fork"
|
HOOK_EVENT_FORK HookEventType = "fork"
|
||||||
HOOK_EVENT_PUSH HookEventType = "push"
|
HOOK_EVENT_PUSH HookEventType = "push"
|
||||||
|
HOOK_EVENT_ISSUES HookEventType = "issues"
|
||||||
HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request"
|
HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -492,6 +500,10 @@ func prepareHookTasks(e Engine, repo *Repository, event HookEventType, p api.Pay
|
||||||
if !w.HasPushEvent() {
|
if !w.HasPushEvent() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
case HOOK_EVENT_ISSUES:
|
||||||
|
if !w.HasIssuesEvent() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
case HOOK_EVENT_PULL_REQUEST:
|
case HOOK_EVENT_PULL_REQUEST:
|
||||||
if !w.HasPullRequestEvent() {
|
if !w.HasPullRequestEvent() {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -169,6 +169,78 @@ func getDiscordPushPayload(p *api.PushPayload, slack *SlackMeta) (*DiscordPayloa
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDiscordIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*DiscordPayload, error) {
|
||||||
|
title := fmt.Sprintf("#%d %s", p.Index, p.Issue.Title)
|
||||||
|
url := fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index)
|
||||||
|
content := ""
|
||||||
|
fields := make([]*DiscordEmbedFieldObject, 0, 1)
|
||||||
|
switch p.Action {
|
||||||
|
case api.HOOK_ISSUE_OPENED:
|
||||||
|
title = "New issue: " + title
|
||||||
|
content = p.Issue.Body
|
||||||
|
case api.HOOK_ISSUE_CLOSED:
|
||||||
|
title = "Issue closed: " + title
|
||||||
|
case api.HOOK_ISSUE_REOPENED:
|
||||||
|
title = "Issue re-opened: " + title
|
||||||
|
case api.HOOK_ISSUE_EDITED:
|
||||||
|
title = "Issue edited: " + title
|
||||||
|
content = p.Issue.Body
|
||||||
|
case api.HOOK_ISSUE_ASSIGNED:
|
||||||
|
title = "Issue assigned: " + title
|
||||||
|
fields = []*DiscordEmbedFieldObject{{
|
||||||
|
Name: "New Assignee",
|
||||||
|
Value: p.Issue.Assignee.UserName,
|
||||||
|
}}
|
||||||
|
case api.HOOK_ISSUE_UNASSIGNED:
|
||||||
|
title = "Issue unassigned: " + title
|
||||||
|
case api.HOOK_ISSUE_LABEL_UPDATED:
|
||||||
|
title = "Issue labels updated: " + title
|
||||||
|
labels := make([]string, len(p.Issue.Labels))
|
||||||
|
for i := range p.Issue.Labels {
|
||||||
|
labels[i] = p.Issue.Labels[i].Name
|
||||||
|
}
|
||||||
|
if len(labels) == 0 {
|
||||||
|
labels = []string{"<empty>"}
|
||||||
|
}
|
||||||
|
fields = []*DiscordEmbedFieldObject{{
|
||||||
|
Name: "Labels",
|
||||||
|
Value: strings.Join(labels, ", "),
|
||||||
|
}}
|
||||||
|
case api.HOOK_ISSUE_LABEL_CLEARED:
|
||||||
|
title = "Issue labels cleared: " + title
|
||||||
|
case api.HOOK_ISSUE_SYNCHRONIZED:
|
||||||
|
title = "Issue synchronized: " + title
|
||||||
|
case api.HOOK_ISSUE_MILESTONED:
|
||||||
|
title = "Issue milestoned: " + title
|
||||||
|
fields = []*DiscordEmbedFieldObject{{
|
||||||
|
Name: "New Milestone",
|
||||||
|
Value: p.Issue.Milestone.Title,
|
||||||
|
}}
|
||||||
|
case api.HOOK_ISSUE_DEMILESTONED:
|
||||||
|
title = "Issue demilestoned: " + title
|
||||||
|
}
|
||||||
|
|
||||||
|
color, _ := strconv.ParseInt(strings.TrimLeft(slack.Color, "#"), 16, 32)
|
||||||
|
return &DiscordPayload{
|
||||||
|
Username: slack.Username,
|
||||||
|
AvatarURL: slack.IconURL,
|
||||||
|
Embeds: []*DiscordEmbedObject{{
|
||||||
|
Title: title,
|
||||||
|
Description: content,
|
||||||
|
URL: url,
|
||||||
|
Color: int(color),
|
||||||
|
Footer: &DiscordEmbedFooterObject{
|
||||||
|
Text: p.Repository.FullName,
|
||||||
|
},
|
||||||
|
Author: &DiscordEmbedAuthorObject{
|
||||||
|
Name: p.Sender.UserName,
|
||||||
|
IconURL: p.Sender.AvatarUrl,
|
||||||
|
},
|
||||||
|
Fields: fields,
|
||||||
|
}},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getDiscordPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*DiscordPayload, error) {
|
func getDiscordPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*DiscordPayload, error) {
|
||||||
title := fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)
|
title := fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)
|
||||||
url := fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index)
|
url := fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index)
|
||||||
|
@ -211,6 +283,14 @@ func getDiscordPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (
|
||||||
title = "Pull request labels cleared: " + title
|
title = "Pull request labels cleared: " + title
|
||||||
case api.HOOK_ISSUE_SYNCHRONIZED:
|
case api.HOOK_ISSUE_SYNCHRONIZED:
|
||||||
title = "Pull request synchronized: " + title
|
title = "Pull request synchronized: " + title
|
||||||
|
case api.HOOK_ISSUE_MILESTONED:
|
||||||
|
title = "Pull request milestoned: " + title
|
||||||
|
fields = []*DiscordEmbedFieldObject{{
|
||||||
|
Name: "New Milestone",
|
||||||
|
Value: p.PullRequest.Milestone.Title,
|
||||||
|
}}
|
||||||
|
case api.HOOK_ISSUE_DEMILESTONED:
|
||||||
|
title = "Pull request demilestoned: " + title
|
||||||
}
|
}
|
||||||
|
|
||||||
color, _ := strconv.ParseInt(strings.TrimLeft(slack.Color, "#"), 16, 32)
|
color, _ := strconv.ParseInt(strings.TrimLeft(slack.Color, "#"), 16, 32)
|
||||||
|
@ -249,6 +329,8 @@ func GetDiscordPayload(p api.Payloader, event HookEventType, meta string) (paylo
|
||||||
payload, err = getDiscordForkPayload(p.(*api.ForkPayload))
|
payload, err = getDiscordForkPayload(p.(*api.ForkPayload))
|
||||||
case HOOK_EVENT_PUSH:
|
case HOOK_EVENT_PUSH:
|
||||||
payload, err = getDiscordPushPayload(p.(*api.PushPayload), slack)
|
payload, err = getDiscordPushPayload(p.(*api.PushPayload), slack)
|
||||||
|
case HOOK_EVENT_ISSUES:
|
||||||
|
payload, err = getDiscordIssuesPayload(p.(*api.IssuesPayload), slack)
|
||||||
case HOOK_EVENT_PULL_REQUEST:
|
case HOOK_EVENT_PULL_REQUEST:
|
||||||
payload, err = getDiscordPullRequestPayload(p.(*api.PullRequestPayload), slack)
|
payload, err = getDiscordPullRequestPayload(p.(*api.PullRequestPayload), slack)
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,52 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayload, error) {
|
||||||
|
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
|
||||||
|
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index),
|
||||||
|
fmt.Sprintf("#%d %s", p.Index, p.Issue.Title))
|
||||||
|
var text, title, attachmentText string
|
||||||
|
switch p.Action {
|
||||||
|
case api.HOOK_ISSUE_OPENED:
|
||||||
|
text = fmt.Sprintf("[%s] New issue created by %s", p.Repository.FullName, senderLink)
|
||||||
|
title = titleLink
|
||||||
|
attachmentText = SlackTextFormatter(p.Issue.Body)
|
||||||
|
case api.HOOK_ISSUE_CLOSED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue closed: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_REOPENED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_EDITED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue edited: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
attachmentText = SlackTextFormatter(p.Issue.Body)
|
||||||
|
case api.HOOK_ISSUE_ASSIGNED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", p.Repository.FullName,
|
||||||
|
SlackLinkFormatter(setting.AppUrl+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
|
||||||
|
titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_UNASSIGNED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_LABEL_UPDATED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue labels updated: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_LABEL_CLEARED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_MILESTONED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue milestoned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_DEMILESTONED:
|
||||||
|
text = fmt.Sprintf("[%s] Issue demilestoned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SlackPayload{
|
||||||
|
Channel: slack.Channel,
|
||||||
|
Text: text,
|
||||||
|
Username: slack.Username,
|
||||||
|
IconURL: slack.IconURL,
|
||||||
|
Attachments: []*SlackAttachment{{
|
||||||
|
Color: slack.Color,
|
||||||
|
Title: title,
|
||||||
|
Text: attachmentText,
|
||||||
|
}},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
|
func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
|
||||||
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
|
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
|
||||||
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index),
|
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index),
|
||||||
|
@ -178,6 +224,10 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
|
||||||
text = fmt.Sprintf("[%s] Pull request labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
text = fmt.Sprintf("[%s] Pull request labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
case api.HOOK_ISSUE_SYNCHRONIZED:
|
case api.HOOK_ISSUE_SYNCHRONIZED:
|
||||||
text = fmt.Sprintf("[%s] Pull request synchronized: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
text = fmt.Sprintf("[%s] Pull request synchronized: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_MILESTONED:
|
||||||
|
text = fmt.Sprintf("[%s] Pull request milestoned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
|
case api.HOOK_ISSUE_DEMILESTONED:
|
||||||
|
text = fmt.Sprintf("[%s] Pull request demilestoned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &SlackPayload{
|
return &SlackPayload{
|
||||||
|
@ -208,6 +258,8 @@ func GetSlackPayload(p api.Payloader, event HookEventType, meta string) (payload
|
||||||
payload, err = getSlackForkPayload(p.(*api.ForkPayload))
|
payload, err = getSlackForkPayload(p.(*api.ForkPayload))
|
||||||
case HOOK_EVENT_PUSH:
|
case HOOK_EVENT_PUSH:
|
||||||
payload, err = getSlackPushPayload(p.(*api.PushPayload), slack)
|
payload, err = getSlackPushPayload(p.(*api.PushPayload), slack)
|
||||||
|
case HOOK_EVENT_ISSUES:
|
||||||
|
payload, err = getSlackIssuesPayload(p.(*api.IssuesPayload), slack)
|
||||||
case HOOK_EVENT_PULL_REQUEST:
|
case HOOK_EVENT_PULL_REQUEST:
|
||||||
payload, err = getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
|
payload, err = getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -138,6 +138,7 @@ type Webhook struct {
|
||||||
Delete bool
|
Delete bool
|
||||||
Fork bool
|
Fork bool
|
||||||
Push bool
|
Push bool
|
||||||
|
Issues bool
|
||||||
PullRequest bool
|
PullRequest bool
|
||||||
Active bool
|
Active bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||||
issue.MilestoneID != *form.Milestone {
|
issue.MilestoneID != *form.Milestone {
|
||||||
oldMilestoneID := issue.MilestoneID
|
oldMilestoneID := issue.MilestoneID
|
||||||
issue.MilestoneID = *form.Milestone
|
issue.MilestoneID = *form.Milestone
|
||||||
if err = models.ChangeMilestoneAssign(issue, oldMilestoneID); err != nil {
|
if err = models.ChangeMilestoneAssign(ctx.User, issue, oldMilestoneID); err != nil {
|
||||||
ctx.Error(500, "ChangeMilestoneAssign", err)
|
ctx.Error(500, "ChangeMilestoneAssign", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -771,7 +771,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
|
||||||
|
|
||||||
// Not check for invalid milestone id and give responsibility to owners.
|
// Not check for invalid milestone id and give responsibility to owners.
|
||||||
issue.MilestoneID = milestoneID
|
issue.MilestoneID = milestoneID
|
||||||
if err := models.ChangeMilestoneAssign(issue, oldMilestoneID); err != nil {
|
if err := models.ChangeMilestoneAssign(ctx.User, issue, oldMilestoneID); err != nil {
|
||||||
ctx.Handle(500, "ChangeMilestoneAssign", err)
|
ctx.Handle(500, "ChangeMilestoneAssign", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ func ParseHookEvent(f form.Webhook) *models.HookEvent {
|
||||||
Delete: f.Delete,
|
Delete: f.Delete,
|
||||||
Fork: f.Fork,
|
Fork: f.Fork,
|
||||||
Push: f.Push,
|
Push: f.Push,
|
||||||
|
Issues: f.Issues,
|
||||||
PullRequest: f.PullRequest,
|
PullRequest: f.PullRequest,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.10.10.0308
|
0.10.11.0308
|
|
@ -62,6 +62,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Issues -->
|
||||||
|
<div class="seven wide column">
|
||||||
|
<div class="field">
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input class="hidden" name="issues" type="checkbox" tabindex="0" {{if .Webhook.Issues}}checked{{end}}>
|
||||||
|
<label>{{.i18n.Tr "repo.settings.event_issue"}}</label>
|
||||||
|
<span class="help">{{.i18n.Tr "repo.settings.event_issue_desc"}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- Pull Request -->
|
<!-- Pull Request -->
|
||||||
<div class="seven wide column">
|
<div class="seven wide column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return "0.12.7"
|
return "0.12.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client represents a Gogs API client.
|
// Client represents a Gogs API client.
|
||||||
|
|
|
@ -239,6 +239,8 @@ const (
|
||||||
HOOK_ISSUE_UNASSIGNED HookIssueAction = "unassigned"
|
HOOK_ISSUE_UNASSIGNED HookIssueAction = "unassigned"
|
||||||
HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
|
HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
|
||||||
HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
|
HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
|
||||||
|
HOOK_ISSUE_MILESTONED HookIssueAction = "milestoned"
|
||||||
|
HOOK_ISSUE_DEMILESTONED HookIssueAction = "demilestoned"
|
||||||
HOOK_ISSUE_SYNCHRONIZED HookIssueAction = "synchronized"
|
HOOK_ISSUE_SYNCHRONIZED HookIssueAction = "synchronized"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -251,6 +253,19 @@ type ChangesPayload struct {
|
||||||
Body *ChangesFromPayload `json:"body,omitempty"`
|
Body *ChangesFromPayload `json:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IssuesPayload struct {
|
||||||
|
Action HookIssueAction `json:"action"`
|
||||||
|
Index int64 `json:"number"`
|
||||||
|
Issue *Issue `json:"issue"`
|
||||||
|
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||||
|
Repository *Repository `json:"repository"`
|
||||||
|
Sender *User `json:"sender"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *IssuesPayload) JSONPayload() ([]byte, error) {
|
||||||
|
return json.MarshalIndent(p, "", " ")
|
||||||
|
}
|
||||||
|
|
||||||
// __________ .__ .__ __________ __
|
// __________ .__ .__ __________ __
|
||||||
// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
|
// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
|
||||||
// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
|
// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
|
||||||
|
@ -262,8 +277,8 @@ type ChangesPayload struct {
|
||||||
type PullRequestPayload struct {
|
type PullRequestPayload struct {
|
||||||
Action HookIssueAction `json:"action"`
|
Action HookIssueAction `json:"action"`
|
||||||
Index int64 `json:"number"`
|
Index int64 `json:"number"`
|
||||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
|
||||||
PullRequest *PullRequest `json:"pull_request"`
|
PullRequest *PullRequest `json:"pull_request"`
|
||||||
|
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||||
Repository *Repository `json:"repository"`
|
Repository *Repository `json:"repository"`
|
||||||
Sender *User `json:"sender"`
|
Sender *User `json:"sender"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,13 @@ type User struct {
|
||||||
AvatarUrl string `json:"avatar_url"`
|
AvatarUrl string `json:"avatar_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
// MarshalJSON implements the json.Marshaler interface for User
|
||||||
func (u User) MarshalJSON() ([]byte, error) {
|
func (u User) MarshalJSON() ([]byte, error) {
|
||||||
// Re-declaring User to avoid recursion
|
// Re-declaring User to avoid recursion
|
||||||
type shadow User
|
type shadow User
|
||||||
return json.Marshal(struct {
|
return json.Marshal(struct {
|
||||||
shadow
|
shadow
|
||||||
|
// LEGACY [Gogs 1.0]: remove field(s) for backward compatibility
|
||||||
CompatUserName string `json:"username"`
|
CompatUserName string `json:"username"`
|
||||||
}{shadow(u), u.UserName})
|
}{shadow(u), u.UserName})
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,10 +165,10 @@
|
||||||
"revisionTime": "2017-02-19T18:16:29Z"
|
"revisionTime": "2017-02-19T18:16:29Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "sAGNvN2IXzD+rra6Y9sxJBpR4L8=",
|
"checksumSHA1": "Ut3Nu1GaTwTt+Q4k+t9tV3/3nF8=",
|
||||||
"path": "github.com/gogits/go-gogs-client",
|
"path": "github.com/gogits/go-gogs-client",
|
||||||
"revision": "264a3d5bc98e108f17cc055338dbf4b94faf0d21",
|
"revision": "559fec59f2c88391ba624da5c40f77c49d8c84eb",
|
||||||
"revisionTime": "2017-02-25T08:33:02Z"
|
"revisionTime": "2017-03-09T05:00:34Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "p4yoFWgDiTfpu1JYgh26t6+VDTk=",
|
"checksumSHA1": "p4yoFWgDiTfpu1JYgh26t6+VDTk=",
|
||||||
|
|
Loading…
Reference in New Issue