@@ -94,6 +94,8 @@ Gitea or set your environment appropriately.`, "")
94
94
newCommitIDs := make ([]string , hookBatchSize )
95
95
refFullNames := make ([]string , hookBatchSize )
96
96
count := 0
97
+ total := 0
98
+ lastline := 0
97
99
98
100
for scanner .Scan () {
99
101
// TODO: support news feeds for wiki
@@ -109,14 +111,22 @@ Gitea or set your environment appropriately.`, "")
109
111
oldCommitID := string (fields [0 ])
110
112
newCommitID := string (fields [1 ])
111
113
refFullName := string (fields [2 ])
114
+ total ++
115
+ lastline ++
112
116
113
117
// If the ref is a branch, check if it's protected
114
118
if strings .HasPrefix (refFullName , git .BranchPrefix ) {
115
119
oldCommitIDs [count ] = oldCommitID
116
120
newCommitIDs [count ] = newCommitID
117
121
refFullNames [count ] = refFullName
118
122
count ++
123
+ fmt .Fprintf (os .Stdout , "*" )
124
+ os .Stdout .Sync ()
125
+
119
126
if count >= hookBatchSize {
127
+ fmt .Fprintf (os .Stdout , " Checking %d branches\n " , count )
128
+ os .Stdout .Sync ()
129
+
120
130
hookOptions .OldCommitIDs = oldCommitIDs
121
131
hookOptions .NewCommitIDs = newCommitIDs
122
132
hookOptions .RefFullNames = refFullNames
@@ -128,7 +138,16 @@ Gitea or set your environment appropriately.`, "")
128
138
fail (msg , "" )
129
139
}
130
140
count = 0
141
+ lastline = 0
131
142
}
143
+ } else {
144
+ fmt .Fprintf (os .Stdout , "." )
145
+ os .Stdout .Sync ()
146
+ }
147
+ if lastline >= hookBatchSize {
148
+ fmt .Fprintf (os .Stdout , "\n " )
149
+ os .Stdout .Sync ()
150
+ lastline = 0
132
151
}
133
152
}
134
153
@@ -137,15 +156,25 @@ Gitea or set your environment appropriately.`, "")
137
156
hookOptions .NewCommitIDs = newCommitIDs [:count ]
138
157
hookOptions .RefFullNames = refFullNames [:count ]
139
158
159
+ fmt .Fprintf (os .Stdout , " Checking %d branches\n " , count )
160
+ os .Stdout .Sync ()
161
+
140
162
statusCode , msg := private .HookPreReceive (username , reponame , hookOptions )
141
163
switch statusCode {
142
164
case http .StatusInternalServerError :
143
165
fail ("Internal Server Error" , msg )
144
166
case http .StatusForbidden :
145
167
fail (msg , "" )
146
168
}
169
+ } else if lastline > 0 {
170
+ fmt .Fprintf (os .Stdout , "\n " )
171
+ os .Stdout .Sync ()
172
+ lastline = 0
147
173
}
148
174
175
+ fmt .Fprintf (os .Stdout , "Checked %d references in total\n " , total )
176
+ os .Stdout .Sync ()
177
+
149
178
return nil
150
179
}
151
180
@@ -211,17 +240,17 @@ Gitea or set your environment appropriately.`, "")
211
240
continue
212
241
}
213
242
214
- fmt .Fprintf (os .Stderr , "." )
243
+ fmt .Fprintf (os .Stdout , "." )
215
244
oldCommitIDs [count ] = string (fields [0 ])
216
245
newCommitIDs [count ] = string (fields [1 ])
217
246
refFullNames [count ] = string (fields [2 ])
218
247
count ++
219
248
total ++
220
- os .Stderr .Sync ()
249
+ os .Stdout .Sync ()
221
250
222
251
if count >= hookBatchSize {
223
- fmt .Fprintf (os .Stderr , " Processing %d references\n " , count )
224
- os .Stderr .Sync ()
252
+ fmt .Fprintf (os .Stdout , " Processing %d references\n " , count )
253
+ os .Stdout .Sync ()
225
254
hookOptions .OldCommitIDs = oldCommitIDs
226
255
hookOptions .NewCommitIDs = newCommitIDs
227
256
hookOptions .RefFullNames = refFullNames
@@ -237,8 +266,8 @@ Gitea or set your environment appropriately.`, "")
237
266
238
267
if count == 0 {
239
268
240
- fmt .Fprintf (os .Stderr , "Processed %d references in total\n " , total )
241
- os .Stderr .Sync ()
269
+ fmt .Fprintf (os .Stdout , "Processed %d references in total\n " , total )
270
+ os .Stdout .Sync ()
242
271
243
272
return nil
244
273
}
@@ -247,8 +276,8 @@ Gitea or set your environment appropriately.`, "")
247
276
hookOptions .NewCommitIDs = newCommitIDs [:count ]
248
277
hookOptions .RefFullNames = refFullNames [:count ]
249
278
250
- fmt .Fprintf (os .Stderr , " Processing %d references\n " , count )
251
- os .Stderr .Sync ()
279
+ fmt .Fprintf (os .Stdout , " Processing %d references\n " , count )
280
+ os .Stdout .Sync ()
252
281
253
282
resps , err := private .HookPostReceive (repoUser , repoName , hookOptions )
254
283
if resps == nil {
@@ -257,8 +286,8 @@ Gitea or set your environment appropriately.`, "")
257
286
}
258
287
results = append (results , resps ... )
259
288
260
- fmt .Fprintf (os .Stderr , "Processed %d references in total\n " , total )
261
- os .Stderr .Sync ()
289
+ fmt .Fprintf (os .Stdout , "Processed %d references in total\n " , total )
290
+ os .Stdout .Sync ()
262
291
263
292
hookPrintResults (results )
264
293
0 commit comments