use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method should_use_modification_revision_when_revision_before_is_invalid_sha.
public void should_use_modification_revision_when_revision_before_is_invalid_sha() throws Exception {
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("master").build();
VcsModification m = new MockVcsModification("3b9fbfbb43e7edfad018b482e15e7f93cca4e69f");
String invalidSHA = "invalidSHA";
VcsChangeInfo change = new VcsChange(VcsChangeInfo.Type.CHANGED, "readme.txt", "readme.txt", invalidSHA, null);
byte[] actual = git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.BEFORE_CHANGE, root);
byte[] expected = "Test repository for teamcity.".getBytes();
assertEquals(expected, actual);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method should_throw_error_when_cannot_get_valid_version.
public void should_throw_error_when_cannot_get_valid_version() throws VcsException {
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("version-test").build();
VcsModification m = new MockVcsModification("invalidSHA");
VcsChangeInfo change = new VcsChange(VcsChangeInfo.Type.CHANGED, "readme.txt", "readme.txt", "invalidSHA", "invalidSHA");
try {
git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.BEFORE_CHANGE, root);
fail("should fail");
} catch (VcsException e) {
assertTrue(e.getMessage().contains("Invalid version 'invalidSHA'"));
}
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class ContentProviderTest method should_use_modification_revision_when_revision_before_is_null.
public void should_use_modification_revision_when_revision_before_is_null() throws Exception {
GitVcsSupport git = createGit();
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("master").build();
VcsModification m = new MockVcsModification("3b9fbfbb43e7edfad018b482e15e7f93cca4e69f");
VcsChangeInfo change = new VcsChange(VcsChangeInfo.Type.CHANGED, "readme.txt", "readme.txt", null, null);
byte[] actual = git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.BEFORE_CHANGE, root);
byte[] expected = "Test repository for teamcity.".getBytes();
assertEquals(expected, actual);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class BranchSupportTest method test.
/**
* o ee886e4adb70fbe3bdc6f3f6393598b3f02e8009 (change1)
* |
* |
* | o 1391281d33a83a7205f2f05d3eb64c349c636e87 (change2)
* | |
* | /
* |/
* o f3f826ce85d6dad25156b2d7550cedeb1a422f4c
* |
* |
* |
*/
public void test() throws VcsException {
VcsRoot originalRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
VcsRoot substitutionRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("personal-branch1").build();
final String originalRootVersion = "3b9fbfbb43e7edfad018b482e15e7f93cca4e69f";
final String substitutionRootVersion = "1391281d33a83a7205f2f05d3eb64c349c636e87";
GitVcsSupport vcsSupport = gitSupport().withServerPaths(myServerPaths).build();
List<ModificationData> changes = vcsSupport.collectChanges(originalRoot, originalRootVersion, substitutionRoot, substitutionRootVersion, CheckoutRules.DEFAULT);
assertEquals(1, changes.size());
assertEquals(substitutionRoot, changes.get(0).getVcsRootObject());
assertEquals(substitutionRootVersion, changes.get(0).getVersion());
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.
the class GitCommitsInfoBuilderTest method test_torrents_repo_local.
@Test(enabled = false)
public void test_torrents_repo_local() throws VcsException {
// /does not work for real repository: Fetcher call is mostly endless
VcsRoot root = vcsRoot().withFetchUrl("E:\\Work\\TeamCity\\trunk\\teamcity-torrent-plugin\\.git").withRepositoryPathOnServer("E:\\Work\\TeamCity\\trunk\\teamcity-torrent-plugin\\.git").withBranch("master").build();
GitVcsSupport vcs = gitSupport().withServerPaths(myServerPaths).build();
final List<CommitInfo> commits = new ArrayList<CommitInfo>();
new GitCommitsInfoBuilder(vcs, new GitFetchService(vcs)).collectCommits(root, CheckoutRules.DEFAULT, new CommitsInfoBuilder.CommitsConsumer() {
public void consumeCommit(@NotNull CommitInfo commit) {
commits.add(commit);
}
});
System.out.println("Total commits: " + commits.size());
}
Aggregations