initial completion
This commit is contained in:
@@ -83,9 +83,30 @@ func (h *PRHandler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Auto-assign default reviewers.
|
||||
AutoAssignReviewers(h.db, repoID, pr.ID)
|
||||
|
||||
// Fire webhook.
|
||||
go FireWebhooks(h.db, repoID, "pull_request", map[string]interface{}{
|
||||
"action": "opened",
|
||||
"pullRequest": map[string]interface{}{"id": pr.ID, "title": pr.Title},
|
||||
})
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
json.NewEncoder(w).Encode(pr)
|
||||
json.NewEncoder(w).Encode(prWithReviewers(h.db, pr))
|
||||
}
|
||||
|
||||
type prResponse struct {
|
||||
models.PullRequest
|
||||
Reviewers []ReviewerInfo `json:"reviewers"`
|
||||
}
|
||||
|
||||
func prWithReviewers(db *xorm.Engine, pr *models.PullRequest) prResponse {
|
||||
return prResponse{
|
||||
PullRequest: *pr,
|
||||
Reviewers: GetPrReviewers(db, pr.ID),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *PRHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -93,7 +114,7 @@ func (h *PRHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
jsonOK(w, pr)
|
||||
jsonOK(w, prWithReviewers(h.db, pr))
|
||||
}
|
||||
|
||||
func (h *PRHandler) Merge(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user