Search in sources :

Example 26 with GitVcsSupport

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);
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)

Example 27 with GitVcsSupport

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'"));
    }
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)

Example 28 with GitVcsSupport

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);
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)

Example 29 with GitVcsSupport

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());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) ModificationData(jetbrains.buildServer.vcs.ModificationData) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 30 with GitVcsSupport

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());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) GitCommitsInfoBuilder(jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.GitCommitsInfoBuilder) GitCommitsInfoBuilder(jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.GitCommitsInfoBuilder) CommitInfo(jetbrains.vcs.api.CommitInfo) GitFetchService(jetbrains.buildServer.buildTriggers.vcs.git.GitFetchService) Test(org.testng.annotations.Test)

Aggregations

GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)31 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)15 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)10 Test (org.testng.annotations.Test)9 GitFetchService (jetbrains.buildServer.buildTriggers.vcs.git.GitFetchService)6 GitCommitsInfoBuilder (jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.GitCommitsInfoBuilder)5 CommitInfo (jetbrains.vcs.api.CommitInfo)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PatchBuilderImpl (jetbrains.buildServer.vcs.patches.PatchBuilderImpl)3 File (java.io.File)2 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)2 HashSet (java.util.HashSet)1 OperationContext (jetbrains.buildServer.buildTriggers.vcs.git.OperationContext)1 ModificationData (jetbrains.buildServer.vcs.ModificationData)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 CommitMountPointInfo (jetbrains.vcs.api.CommitMountPointInfo)1 MissingObjectException (org.eclipse.jgit.errors.MissingObjectException)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1