Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook for Pull Request approval/rejection #5027

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
17f9a87
started work on allowing pr approval/rejection... Untested though
adelowo Oct 6, 2018
1d478c9
whoops
adelowo Oct 6, 2018
b5564d6
fix pr#Issue being nil
adelowo Oct 6, 2018
e92bef5
updated hook name
adelowo Oct 6, 2018
b549837
properly format webhook for slack
adelowo Oct 6, 2018
d2cfc93
remove redundant newline
adelowo Oct 6, 2018
8969baf
remove redundant comment
adelowo Oct 6, 2018
5ed0dbc
fix make lint
adelowo Oct 6, 2018
59f4f5a
fix build
adelowo Oct 6, 2018
1923bd9
add webhook formatting for discord
adelowo Oct 6, 2018
50f4846
add webhook formatting for dingtalk
adelowo Oct 6, 2018
ce77646
try to fix naming
adelowo Oct 6, 2018
d517038
Merge branch 'master' of https://github.com/go-gitea/gitea into webho…
adelowo Oct 6, 2018
73fc34e
Merge remote-tracking branch 'origin/master' into webhook_for_pr_appr…
adelowo Oct 9, 2018
d1c234c
add error handling
adelowo Oct 9, 2018
67259f0
fix style guide
adelowo Oct 9, 2018
0770f77
add support for pull request comment webhooks
adelowo Oct 23, 2018
745c619
Merge branch 'master' of https://github.com/go-gitea/gitea into webho…
adelowo Oct 23, 2018
0f698bb
fix naming
adelowo Oct 23, 2018
d2577fc
remove redundant comment and update translations
adelowo Oct 24, 2018
50e0ae1
fix merge conflicts
adelowo Dec 11, 2018
c03bd6f
Merge branch 'master' into webhook_for_pr_approval_rejection
techknowlogick Dec 27, 2018
25f4aac
Merge branch 'master' into webhook_for_pr_approval_rejection
techknowlogick Dec 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix pr#Issue being nil
  • Loading branch information
adelowo committed Oct 6, 2018
commit b5564d62aa94cdd9099b32c55efb5f204183e5a4
1 change: 1 addition & 0 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (pr *PullRequest) APIFormat() *api.PullRequest {
headCommit *git.Commit
err error
)

apiIssue := pr.Issue.APIFormat()
if pr.BaseRepo == nil {
pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID)
Expand Down
19 changes: 12 additions & 7 deletions models/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,30 @@ func createReview(e Engine, opts CreateReviewOptions) (*Review, error) {
}

var reviewHookType HookEventType
var action api.HookIssueAction

if opts.Type == ReviewTypeApprove {
reviewHookType = HookEventPullRequestApproved
action = api.HookPullRequestApproved
} else if opts.Type == ReviewTypeReject {
reviewHookType = HookEventPullRequestRejected
action = api.HookPullRequestRejected
} else {
// Webhook for a review comment does not exists
return review, nil
}

pr := opts.Issue.PullRequest

// For some weird reason, pr#Issues is nil
if err := pr.LoadIssue(); err != nil {
return nil, err
}

mode, _ := AccessLevel(opts.Issue.Poster.ID, opts.Issue.Repo)
if err := PrepareWebhooks(opts.Issue.Repo, reviewHookType, &api.PullRequestPayload{
Action: action,
Index: opts.Issue.Index,
Repository: opts.Issue.Repo.APIFormat(mode),
Sender: opts.Reviewer.APIFormat(),
Action: api.HookIssueSynchronized,
Index: opts.Issue.Index,
PullRequest: pr.APIFormat(),
Repository: opts.Issue.Repo.APIFormat(mode),
Sender: opts.Reviewer.APIFormat(),
}); err != nil {
return nil, err
} else {
Expand Down
6 changes: 0 additions & 6 deletions vendor/code.gitea.io/sdk/gitea/hook.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.