use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method testGetContent.
@Test(dataProvider = "doFetchInSeparateProcess", dataProviderClass = FetchOptionsDataProvider.class)
public void testGetContent(boolean fetchInSeparateProcess) throws Exception {
myConfigBuilder.setSeparateProcessForFetch(fetchInSeparateProcess);
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("version-test").build();
String version = getDefaultBranchRevision(git, root);
byte[] actual = git.getContentProvider().getContent("readme.txt", root, version);
byte[] expected = FileUtil.loadFileBytes(dataFile("content", "readme.txt"));
assertEquals(expected, actual);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method should_use_modification_revision_when_revision_after_is_null.
public void should_use_modification_revision_when_revision_after_is_null() throws Exception {
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("version-test").build();
String version = getDefaultBranchRevision(git, root);
VcsModification m = new MockVcsModification(version);
VcsChangeInfo change = new VcsChange(VcsChangeInfo.Type.CHANGED, "readme.txt", "readme.txt", null, null);
byte[] actual = git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.AFTER_CHANGE, root);
byte[] expected = FileUtil.loadFileBytes(dataFile("content", "readme.txt"));
assertEquals(expected, actual);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method get_content_in_submodules.
@Test(dataProvider = "doFetchInSeparateProcess", dataProviderClass = FetchOptionsDataProvider.class)
public void get_content_in_submodules(boolean fetchInSeparateProcess) throws Exception {
myConfigBuilder.setSeparateProcessForFetch(fetchInSeparateProcess);
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("patch-tests").withSubmodulePolicy(SubmodulesCheckoutPolicy.CHECKOUT).build();
String version = getDefaultBranchRevision(git, root);
byte[] actual = git.getContentProvider().getContent("submodule/file.txt", root, version);
byte[] expected = FileUtil.loadFileBytes(dataFile("content", "submodule file.txt"));
assertEquals(expected, actual);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method should_throw_specific_exception_when_revision_does_not_exist.
public void should_throw_specific_exception_when_revision_does_not_exist() throws VcsException {
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("master").build();
// some non existing revision
VcsModification m = new MockVcsModification("9b9fbfbb43e7edfad018b482e15e7f93cca4e69f");
VcsChangeInfo change = new VcsChange(VcsChangeInfo.Type.CHANGED, "readme.txt", "readme.txt", m.getVersion(), m.getVersion());
try {
git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.AFTER_CHANGE, root);
fail("should fail");
} catch (RevisionNotFoundException e) {
assertTrue(e.getMessage().contains("Cannot find commit " + m.getVersion()));
}
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class LatestAcceptedRevisionTest method merge_commit_tree_does_not_have_difference_with_parents.
/**
* This test is for the following case:
* <pre>
* o m3
* / \
* m1 o o m2
* | \/ |
* c1 o o c2
* | /
* o
* </pre>
* Here m1 and m2 have the same trees, so when m3 is created there is no diff between m3 & m1 and m3 & m2.
* So although both c1 & c2 change interesting files we won't see a diff in trees in m3 comparing to its parents and
* can think that nothing interesting was changed, while this is not true.
*/
public void merge_commit_tree_does_not_have_difference_with_parents() throws VcsException, IOException {
GitVcsSupport support = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
ensureFetchPerformed(support, root, "refs/heads/master", "6399724fac6ec9c62e8795fc037ad385e873911f");
String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
// m3 is 6394695f179d87f7f5fc712e12dfac0ed0d98652
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File6.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File7.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/TestFile5.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("8fc8c2a8baf37a71a2cdd0c2b0cd1eedfd1649e8");
}
Aggregations