Merge "LazyPostReceiveHookChain: Simplify check for pack size" into stable-3.1
This commit is contained in:
@@ -342,7 +342,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
||||
ImmutableList.<PostReceiveHook>builder()
|
||||
.add(
|
||||
(pack, commands) -> {
|
||||
if (affectsSize(pack, commands)) {
|
||||
if (affectsSize(pack)) {
|
||||
try {
|
||||
quotaBackend
|
||||
.user(identifiedUser)
|
||||
|
@@ -61,7 +61,7 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
|
||||
@Override
|
||||
public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
|
||||
hooks.runEach(h -> h.onPostReceive(rp, commands));
|
||||
if (affectsSize(rp, commands)) {
|
||||
if (affectsSize(rp)) {
|
||||
QuotaResponse.Aggregated a =
|
||||
quotaBackend
|
||||
.user(user)
|
||||
@@ -78,21 +78,7 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean affectsSize(ReceivePack rp, Collection<ReceiveCommand> commands) {
|
||||
long packSize;
|
||||
try {
|
||||
packSize = rp.getPackSize();
|
||||
} catch (IllegalStateException e) {
|
||||
// No pack was received, i.e. ref deletion or wind back
|
||||
return false;
|
||||
}
|
||||
if (packSize > 0L) {
|
||||
for (ReceiveCommand cmd : commands) {
|
||||
if (cmd.getType() != ReceiveCommand.Type.DELETE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public static boolean affectsSize(ReceivePack rp) {
|
||||
return rp.hasReceivedPack() && rp.getPackSize() > 0L;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user