|
|
@@ -58,6 +58,8 @@ import java.security.MessageDigest; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.zip.Deflater; |
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
@@ -158,6 +160,45 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas |
|
|
|
assertEquals(B, master.getObjectId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void resetsHaves() throws Exception { |
|
|
|
AtomicReference<Set<ObjectId>> haves = new AtomicReference<>(); |
|
|
|
try (TransportLocal t = new TransportLocal(src, uriOf(dst), |
|
|
|
dst.getDirectory()) { |
|
|
|
@Override |
|
|
|
ReceivePack createReceivePack(Repository db) { |
|
|
|
dst.incrementOpen(); |
|
|
|
|
|
|
|
ReceivePack rp = super.createReceivePack(dst); |
|
|
|
rp.setAdvertiseRefsHook(new AdvertiseRefsHook() { |
|
|
|
@Override |
|
|
|
public void advertiseRefs(BaseReceivePack rp2) |
|
|
|
throws ServiceMayNotContinueException { |
|
|
|
rp.setAdvertisedRefs(rp.getRepository().getAllRefs(), |
|
|
|
null); |
|
|
|
new HidePrivateHook().advertiseRefs(rp); |
|
|
|
haves.set(rp.getAdvertisedObjects()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void advertiseRefs(UploadPack uploadPack) |
|
|
|
throws ServiceMayNotContinueException { |
|
|
|
throw new UnsupportedOperationException(); |
|
|
|
} |
|
|
|
}); |
|
|
|
return rp; |
|
|
|
} |
|
|
|
}) { |
|
|
|
try (PushConnection c = t.openPush()) { |
|
|
|
// Just has to open/close for advertisement. |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
assertEquals(1, haves.get().size()); |
|
|
|
assertTrue(haves.get().contains(B)); |
|
|
|
assertFalse(haves.get().contains(P)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSuccess() throws Exception { |
|
|
|
// Manually force a delta of an object so we reuse it later. |