diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-21 10:28:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 10:28:29 +0800 |
commit | 6bdc556b7f490be7360104b731ce817050cc1d80 (patch) | |
tree | 63887addb45b5b2be1e672580c984497fa9f4112 /models/pull.go | |
parent | dc0ef38950ec8aca78f6e870fb83d1ca68074682 (diff) | |
download | gitea-6bdc556b7f490be7360104b731ce817050cc1d80.tar.gz gitea-6bdc556b7f490be7360104b731ce817050cc1d80.zip |
Fix some webhooks bugs (#3981)
* fix some webhooks bugs
* update vendor
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* fix test
* fix clearlabels
* fix pullrequest webhook bug fix #3492
* update release webhook description
* remove unused code
* fix push webhook in pull request
* small changes
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/models/pull.go b/models/pull.go index d23d885b6c..90b341907d 100644 --- a/models/pull.go +++ b/models/pull.go @@ -457,15 +457,18 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle log.Error(4, "LoadAttributes: %v", err) return nil } + + mode, _ := AccessLevel(doer.ID, pr.Issue.Repo) if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ Action: api.HookIssueClosed, Index: pr.Index, PullRequest: pr.APIFormat(), - Repository: pr.Issue.Repo.APIFormat(AccessModeNone), + Repository: pr.Issue.Repo.APIFormat(mode), Sender: doer.APIFormat(), }); err != nil { log.Error(4, "PrepareWebhooks: %v", err) - return nil + } else { + go HookQueue.Add(pr.Issue.Repo.ID) } l, err := baseGitRepo.CommitsBetweenIDs(pr.MergedCommitID, pr.MergeBase) @@ -492,12 +495,14 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle After: mergeCommit.ID.String(), CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID), Commits: ListToPushCommits(l).ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()), - Repo: pr.BaseRepo.APIFormat(AccessModeNone), + Repo: pr.BaseRepo.APIFormat(mode), Pusher: pr.HeadRepo.MustOwner().APIFormat(), Sender: doer.APIFormat(), } if err = PrepareWebhooks(pr.BaseRepo, HookEventPush, p); err != nil { - return fmt.Errorf("PrepareWebhooks: %v", err) + log.Error(4, "PrepareWebhooks: %v", err) + } else { + go HookQueue.Add(pr.BaseRepo.ID) } return nil } @@ -782,16 +787,18 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str pr.Issue = pull pull.PullRequest = pr + mode, _ := AccessLevel(pull.Poster.ID, repo) if err = PrepareWebhooks(repo, HookEventPullRequest, &api.PullRequestPayload{ Action: api.HookIssueOpened, Index: pull.Index, PullRequest: pr.APIFormat(), - Repository: repo.APIFormat(AccessModeNone), + Repository: repo.APIFormat(mode), Sender: pull.Poster.APIFormat(), }); err != nil { log.Error(4, "PrepareWebhooks: %v", err) + } else { + go HookQueue.Add(repo.ID) } - go HookQueue.Add(repo.ID) return nil } |