@@ -196,6 +196,8 @@ Gitea or set your environment appropriately.`, "")
196
196
newCommitIDs := make ([]string , hookBatchSize )
197
197
refFullNames := make ([]string , hookBatchSize )
198
198
count := 0
199
+ total := 0
200
+ results := make ([]private.HookPostReceiveResult , 0 )
199
201
200
202
scanner := bufio .NewScanner (os .Stdin )
201
203
for scanner .Scan () {
@@ -209,34 +211,26 @@ Gitea or set your environment appropriately.`, "")
209
211
continue
210
212
}
211
213
214
+ fmt .Fprintf (os .Stderr , "." )
212
215
oldCommitIDs [count ] = string (fields [0 ])
213
216
newCommitIDs [count ] = string (fields [1 ])
214
217
refFullNames [count ] = string (fields [2 ])
215
218
count ++
219
+ total ++
220
+ os .Stderr .Sync ()
216
221
217
222
if count >= hookBatchSize {
223
+ fmt .Fprintf (os .Stderr , " Processing %d references\n " , count )
224
+ os .Stderr .Sync ()
218
225
hookOptions .OldCommitIDs = oldCommitIDs
219
226
hookOptions .NewCommitIDs = newCommitIDs
220
227
hookOptions .RefFullNames = refFullNames
221
228
resps , err := private .HookPostReceive (repoUser , repoName , hookOptions )
222
229
if resps == nil {
230
+ hookPrintResults (results )
223
231
fail ("Internal Server Error" , err )
224
232
}
225
- for _ , res := range resps {
226
- if ! res .Message {
227
- continue
228
- }
229
-
230
- fmt .Fprintln (os .Stderr , "" )
231
- if res .Create {
232
- fmt .Fprintf (os .Stderr , "Create a new pull request for '%s':\n " , res .Branch )
233
- fmt .Fprintf (os .Stderr , " %s\n " , res .URL )
234
- } else {
235
- fmt .Fprint (os .Stderr , "Visit the existing pull request:\n " )
236
- fmt .Fprintf (os .Stderr , " %s\n " , res .URL )
237
- }
238
- fmt .Fprintln (os .Stderr , "" )
239
- }
233
+ results = append (results , resps ... )
240
234
count = 0
241
235
}
242
236
}
@@ -248,11 +242,25 @@ Gitea or set your environment appropriately.`, "")
248
242
hookOptions .OldCommitIDs = oldCommitIDs [:count ]
249
243
hookOptions .NewCommitIDs = newCommitIDs [:count ]
250
244
hookOptions .RefFullNames = refFullNames [:count ]
245
+
246
+ fmt .Fprintf (os .Stderr , " Processing %d references\n " , count )
247
+ os .Stderr .Sync ()
248
+ fmt .Fprintf (os .Stderr , "Processed %d references in total\n " , total )
249
+ os .Stderr .Sync ()
250
+
251
251
resps , err := private .HookPostReceive (repoUser , repoName , hookOptions )
252
252
if resps == nil {
253
+ hookPrintResults (results )
253
254
fail ("Internal Server Error" , err )
254
255
}
255
- for _ , res := range resps {
256
+ results = append (results , resps ... )
257
+ hookPrintResults (results )
258
+
259
+ return nil
260
+ }
261
+
262
+ func hookPrintResults (results []private.HookPostReceiveResult ) {
263
+ for _ , res := range results {
256
264
if ! res .Message {
257
265
continue
258
266
}
@@ -266,7 +274,6 @@ Gitea or set your environment appropriately.`, "")
266
274
fmt .Fprintf (os .Stderr , " %s\n " , res .URL )
267
275
}
268
276
fmt .Fprintln (os .Stderr , "" )
277
+ os .Stderr .Sync ()
269
278
}
270
-
271
- return nil
272
279
}
0 commit comments