Add Co-authored-by trailers to Merge's squash commit
This commit is contained in:
@@ -301,6 +301,21 @@ func (s *Server) GetUnmerged(w http.ResponseWriter, r *http.Request, taskID stri
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) GetCoAuthors(w http.ResponseWriter, r *http.Request, taskID string) {
|
||||
_, err := s.store.GetTask(r.Context(), taskID)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
coAuthors, err := s.agents.CoAuthors(r.Context(), taskID, actor(r))
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, coAuthors)
|
||||
}
|
||||
|
||||
func (s *Server) MergeTask(w http.ResponseWriter, r *http.Request, taskID string) {
|
||||
t, p, ok := s.activeTask(w, r, taskID)
|
||||
if !ok {
|
||||
|
||||
@@ -291,7 +291,17 @@ func TestMergeTask(t *testing.T) {
|
||||
task := api.Task{}
|
||||
h.do("POST", "/api/projects/"+p.Id+"/tasks", api.TaskCreate{Title: "Add notes"}, &task)
|
||||
|
||||
code := h.do("POST", "/api/tasks/"+task.Id+"/merge", nil, nil)
|
||||
coAuthors := []api.Participant{}
|
||||
code := h.do("GET", "/api/tasks/"+task.Id+"/co-authors", nil, &coAuthors)
|
||||
if code != http.StatusOK || len(coAuthors) != 0 {
|
||||
t.Fatalf("co-authors: %d %+v", code, coAuthors)
|
||||
}
|
||||
code = h.do("GET", "/api/tasks/nope/co-authors", nil, nil)
|
||||
if code != http.StatusNotFound {
|
||||
t.Fatalf("want 404 for co-authors of an unknown task, got %d", code)
|
||||
}
|
||||
|
||||
code = h.do("POST", "/api/tasks/"+task.Id+"/merge", nil, nil)
|
||||
if code != http.StatusBadRequest {
|
||||
t.Fatalf("want 400 merging without a git identity, got %d", code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user