@@ -94,16 +94,19 @@ func main() {
94
94
func (s * server ) markDeployedPR (w http.ResponseWriter , req * http.Request ) {
95
95
var commitSHA string
96
96
var team string
97
+
97
98
for k , v := range req .URL .Query () {
98
99
switch k {
99
100
case "commit" :
100
101
commitSHA = v [0 ]
101
102
case "team" :
102
103
team = v [0 ]
104
+
103
105
default :
104
106
s .log .Warnf ("Unrecognized parameter received: %s" , k )
105
107
}
106
108
}
109
+
107
110
if team == "" || commitSHA == "" {
108
111
109
112
var preconditionFailed struct {
@@ -127,16 +130,28 @@ func (s *server) markDeployedPR(w http.ResponseWriter, req *http.Request) {
127
130
return
128
131
}
129
132
133
+ var errs []error
134
+
130
135
switch req .Method {
131
136
case "GET" :
132
137
var msg struct {
133
138
PRs struct {
134
139
Labeled []string `json:"labeled"`
135
140
Unlabeled []string `json:"unlabeled"`
136
141
}
137
- Errors []error `json:"errors"`
142
+ Errors []string `json:"errors"`
143
+ }
144
+
145
+ msg .PRs .Labeled , msg .PRs .Unlabeled , errs = s .handleGetUnmarkedPRs (req .Context (), commitSHA , team )
146
+
147
+ msg .Errors = make ([]string , 0 , len (errs ))
148
+ for _ , err := range errs {
149
+ msg .Errors = append (msg .Errors , err .Error ())
150
+ }
151
+
152
+ if len (msg .Errors ) > 0 {
153
+ w .WriteHeader (http .StatusUnprocessableEntity )
138
154
}
139
- msg .PRs .Labeled , msg .PRs .Unlabeled , msg .Errors = s .handleGetUnmarkedPRs (req .Context (), commitSHA , team )
140
155
141
156
enc := json .NewEncoder (w )
142
157
enc .SetIndent ("" , " " )
@@ -150,8 +165,18 @@ func (s *server) markDeployedPR(w http.ResponseWriter, req *http.Request) {
150
165
} `json:"deployedPRs"`
151
166
Errors []error `json:"errors"`
152
167
}
168
+
153
169
msg .DeployedPRs .Team , msg .DeployedPRs .All , msg .Errors = s .handleMarkDeployedPRs (req .Context (), commitSHA , team )
154
170
171
+ msg .Errors = make ([]string , 0 , len (errs ))
172
+ for _ , err := range errs {
173
+ msg .Errors = append (msg .Errors , err .Error ())
174
+ }
175
+
176
+ if len (msg .Errors ) > 0 {
177
+ w .WriteHeader (http .StatusUnprocessableEntity )
178
+ }
179
+
155
180
enc := json .NewEncoder (w )
156
181
enc .SetIndent ("" , " " )
157
182
enc .Encode (msg )
0 commit comments