use of jetbrains.buildServer.buildTriggers.vcs.git.CommitLoader in project teamcity-git by JetBrains.
the class MapFullPathTest method should_not_do_unnecessary_commit_lookup_when_repository_does_not_have_hint_revision.
public void should_not_do_unnecessary_commit_lookup_when_repository_does_not_have_hint_revision() throws Exception {
// root1 contains the commit
// root2 doesn't
final CommitLoader commitLoader = myContext.mock(CommitLoader.class);
final RevCommit commit = myContext.mock(RevCommit.class);
myMapFullPath.setCommitLoader(commitLoader);
final String hintCommit = "a7274ca8e024d98c7d59874f19f21d26ee31d41d";
final String lastCommonCommit1 = "add81050184d3c818560bdd8839f50024c188586";
final String lastCommonCommit2 = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
final String remoteUrl1 = myRemoteRepositoryDir.getAbsolutePath();
final String remoteUrl2 = myRemoteRepositoryDir2.getAbsolutePath();
myContext.checking(new Expectations() {
{
one(commitLoader).findCommit(with(repositoryWithUrl(remoteUrl1)), with(hintCommit));
will(returnValue(commit));
// only single check for repository which doesn't contain a hint commit:
one(commitLoader).findCommit(with(repositoryWithUrl(remoteUrl2)), with(hintCommit));
will(returnValue(null));
}
});
String fullPath1 = hintCommit + "-" + lastCommonCommit1 + "||.";
String fullPath2 = hintCommit + "-" + lastCommonCommit2 + "||.";
OperationContext ctx = myGit.createContext(myRoot, "map full path");
OperationContext ctx2 = myGit.createContext(myRoot2, "map full path");
assertFalse(myMapFullPath.mapFullPath(ctx, myRootEntry, fullPath1).isEmpty());
assertTrue(myMapFullPath.mapFullPath(ctx2, myRootEntry2, fullPath1).isEmpty());
assertFalse(myMapFullPath.mapFullPath(ctx, myRootEntry, fullPath2).isEmpty());
assertTrue(myMapFullPath.mapFullPath(ctx2, myRootEntry2, fullPath2).isEmpty());
assertTrue(myMapFullPath.mapFullPath(ctx2, myRootEntry2, hintCommit + "-" + "any_other_commit").isEmpty());
myContext.assertIsSatisfied();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.CommitLoader in project teamcity-git by JetBrains.
the class MapFullPathTest method should_not_do_unnecessary_commit_lookup_after_fetch.
public void should_not_do_unnecessary_commit_lookup_after_fetch() throws Exception {
final String existingCommit = "a7274ca8e024d98c7d59874f19f21d26ee31d41d";
final String nonExistingCommit = "abababababababababababababababababababab";
final CommitLoader commitLoader = myContext.mock(CommitLoader.class);
final RevCommit commit = myContext.mock(RevCommit.class);
myMapFullPath.setCommitLoader(commitLoader);
myContext.checking(new Expectations() {
{
// ask for existing commit only once:
one(commitLoader).findCommit(with(any(Repository.class)), with(existingCommit));
will(returnValue(commit));
one(commitLoader).findCommit(with(any(Repository.class)), with(nonExistingCommit));
will(returnValue(null));
}
});
RepositoryStateData state0 = RepositoryStateData.createSingleVersionState("a7274ca8e024d98c7d59874f19f21d26ee31d41d");
RepositoryStateData state1 = myGit.getCurrentState(myRoot);
// fetch repository, so mapFullPath works
myGit.getCollectChangesPolicy().collectChanges(myRoot, state0, state1, CheckoutRules.DEFAULT);
OperationContext context = myGit.createContext(myRoot, "map full path");
myMapFullPath.mapFullPath(context, myRootEntry, existingCommit + "||.");
myMapFullPath.mapFullPath(context, myRootEntry, nonExistingCommit + "||.");
remoteRepositoryUpdated();
RepositoryStateData state2 = myGit.getCurrentState(myRoot);
// this fetch should not cause new commit lookup
myGit.getCollectChangesPolicy().collectChanges(myRoot, state1, state2, CheckoutRules.DEFAULT);
myGit.mapFullPath(myRootEntry, existingCommit + "||.");
myGit.mapFullPath(myRootEntry, nonExistingCommit + "||.");
myContext.assertIsSatisfied();
}
Aggregations