use of jetbrains.buildServer.util.cache.ResetCacheHandler in project teamcity-git by JetBrains.
the class GitSupportBuilder method build.
@NotNull
public GitVcsSupport build() {
if (myPluginConfigBuilder == null && myServerPaths == null && myPluginConfig == null)
throw new IllegalStateException("Plugin config or server paths should be set");
if (myPluginConfig == null)
myPluginConfig = myPluginConfigBuilder != null ? myPluginConfigBuilder.build() : new PluginConfigImpl(myServerPaths);
if (myTransportFactory == null)
myTransportFactory = new TransportFactoryImpl(myPluginConfig, myVcsRootSSHKeyManager);
Mockery context = new Mockery();
if (myFetchCommand == null) {
if (myBeforeFetchHook == null) {
myFetchCommand = new FetchCommandImpl(myPluginConfig, myTransportFactory, new FetcherProperties(myPluginConfig), myVcsRootSSHKeyManager);
} else {
final FetchCommand originalCommand = new FetchCommandImpl(myPluginConfig, myTransportFactory, new FetcherProperties(myPluginConfig), myVcsRootSSHKeyManager);
myFetchCommand = (db, fetchURI, settings) -> {
myBeforeFetchHook.run();
originalCommand.fetch(db, fetchURI, settings);
};
}
}
MirrorManager mirrorManager = new MirrorManagerImpl(myPluginConfig, new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl());
myRepositoryManager = new RepositoryManagerImpl(myPluginConfig, mirrorManager);
final ResetCacheRegister resetCacheManager;
if (myResetCacheManager == null) {
context.setImposteriser(ClassImposteriser.INSTANCE);
resetCacheManager = context.mock(ResetCacheRegister.class);
context.checking(new Expectations() {
{
allowing(resetCacheManager).registerHandler(with(any(ResetCacheHandler.class)));
}
});
} else {
resetCacheManager = myResetCacheManager;
}
RevisionsCache revisionsCache = new RevisionsCache(myPluginConfig);
myMapFullPath = new GitMapFullPath(myPluginConfig, revisionsCache);
final GitRepoOperationsImpl gitRepoOperations = new GitRepoOperationsImpl(myPluginConfig, myTransportFactory, myVcsRootSSHKeyManager, myFetchCommand);
myCommitLoader = new CommitLoaderImpl(myRepositoryManager, gitRepoOperations, myMapFullPath, myPluginConfig);
GitResetCacheHandler resetCacheHandler = new GitResetCacheHandler(myRepositoryManager, new GcErrors());
ResetRevisionsCacheHandler resetRevisionsCacheHandler = new ResetRevisionsCacheHandler(revisionsCache);
TokenRefresher tokenRefresher = new TokenRefresher() {
@Nullable
@Override
public OAuthToken getRefreshableToken(@NotNull String vcsRootExtId, @NotNull String tokenFullId) {
return null;
}
@Nullable
@Override
public OAuthToken getRefreshableToken(@NotNull SProject project, @NotNull String tokenFullId) {
return null;
}
};
GitVcsSupport git = new GitVcsSupport(gitRepoOperations, myPluginConfig, resetCacheManager, myTransportFactory, myRepositoryManager, myMapFullPath, myCommitLoader, myVcsRootSSHKeyManager, new MockVcsOperationProgressProvider(), resetCacheHandler, resetRevisionsCacheHandler, tokenRefresher, myTestConnectionSupport);
git.addExtensions(myExtensions);
git.setExtensionHolder(myExtensionHolder);
return git;
}
use of jetbrains.buildServer.util.cache.ResetCacheHandler in project teamcity-git by JetBrains.
the class CollectChangesTest method collect_changes_after_cache_reset.
public void collect_changes_after_cache_reset() throws Exception {
GitVcsSupport git = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
git.collectChanges(root, "2c7e90053e0f7a5dd25ea2a16ef8909ba71826f6", "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", CheckoutRules.DEFAULT);
ServerPluginConfig config = myConfig.build();
MirrorManager mirrorManager = new MirrorManagerImpl(config, new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl());
RepositoryManager repositoryManager = new RepositoryManagerImpl(config, mirrorManager);
ResetCacheHandler resetHandler = new GitResetCacheHandler(repositoryManager, new GcErrors());
for (String cache : resetHandler.listCaches()) resetHandler.resetCache(cache);
try {
git.collectChanges(root, "2c7e90053e0f7a5dd25ea2a16ef8909ba71826f6", "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", CheckoutRules.DEFAULT);
} catch (VcsException e) {
fail("Reset of caches breaks repository");
}
}
Aggregations