Search in sources :

Example 1 with GitVcsSupport

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.

the class GitCommitsInfoBuilderTest method test_fetch_service_cache.

public void test_fetch_service_cache() throws Exception {
    VcsRootImpl root = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
    root.addProperty("INCLUDE_COMMIT_INFO_SUBMODULES", "true");
    GitVcsSupport vcs = gitSupport().withServerPaths(myServerPaths).build();
    final GitFetchService svc = new GitFetchService(vcs);
    // init cache
    svc.fetchRepository(root, CheckoutRules.DEFAULT, new FetchService.FetchRepositoryCallback() {

        public void update(final float progress, @NotNull final String message) {
        }
    });
    final OperationContext oc = vcs.createContext(root, "test");
    try {
        assertTime(2, "cache should be used", 2, new Runnable() {

            public void run() {
                try {
                    for (int i = 0; i < 1000; i++) {
                        svc.getOrCreateRepositoryState(oc);
                    }
                } catch (Throwable t) {
                    throw new Error(t);
                }
            }
        });
    } finally {
        oc.close();
    }
}
Also used : OperationContext(jetbrains.buildServer.buildTriggers.vcs.git.OperationContext) GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) GitFetchService(jetbrains.buildServer.buildTriggers.vcs.git.GitFetchService) GitFetchService(jetbrains.buildServer.buildTriggers.vcs.git.GitFetchService)

Example 2 with GitVcsSupport

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.

the class GitCommitsInfoBuilderTest method test_idea_local.

@Test(enabled = false)
public void test_idea_local() throws VcsException {
    // /does not work for real repository: Fetcher call is mostly endless
    VcsRoot root = vcsRoot().withFetchUrl("E:\\Work\\idea-ultimate\\.git").withRepositoryPathOnServer("E:\\Work\\idea-ultimate\\.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)

Example 3 with GitVcsSupport

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.

the class GitCommitsInfoBuilderTest method test.

public void test() throws VcsException {
    VcsRootImpl root = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
    root.addProperty("INCLUDE_COMMIT_INFO_SUBMODULES", "true");
    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);
        }
    });
    List<String> allCommits = asList("ea5e05051fbfaa7d8da97586807b009cbfebae9d", "27de3d118ca320d3a8a08320ff05aa0567996590", "39679cc440c83671fbf6ad8083d92517f9602300", "9395143dd6c3e73abf9281be7a772c4d286e72a5", "039e7395725ad8d2a143fd44645a3fb72b001217", "777f79b3e89e63ac954fe0881470be3c72b8b0d4", "f61e30ce576e76bff877ddf1d00acf22c5c1b07a", "3df61e6f11a5a9b919cb3f786a83fdd09f058617", "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", "5711cbfe566b6c92e331f95d4b236483f4532eed", "6cf3cb6a87091d17466607858c699c35edf30d3b", "2c7e90053e0f7a5dd25ea2a16ef8909ba71826f6", "2494559261ab85e92b1780860b34f876b5e6bce6", "e7f491963fbc5c96a27e4169b97746a5a7f83870", "1391281d33a83a7205f2f05d3eb64c349c636e87", "3b9fbfbb43e7edfad018b482e15e7f93cca4e69f", "e6b15b1f4741199857e2fa744eaadfe5a9d9aede", "feac610f381e697acf4c1c8ad82b7d76c7643b04", "92112555d9eb3e433eaa91fe32ec001ae8fe3c52", "778cc3d0105ca1b6b2587804ebfe89c2557a7e46", "f5bdd3819df0358a43d9a8f94eaf96bb306e19fe", "78cbbed3561de3417467ee819b1795ba14c03dfb", "233daeefb335b60c7b5700afde97f745d86cb40d", "6eae9acd29db2dba146929634a4bb1e6e72a31fd", "ce6044093939bb47283439d97a1c80f759669ff5", "2eed4ae6732536f76a65136a606f635e8ada63b9", "cbf1073bd3f938e7d7d85718dbc6c3bee10360d9", "d1a88fd33c516c1b607db75eb62244b2ea495c42", "37c371a6db0acefc77e3be99d16a44413e746591", "b5d65401a4e8a09b80b8d73ca4392f1913e99ff5", "592c5bcee6d906482177a62a6a44efa0cff9bbc7", "1837cf38309496165054af8bf7d62a9fe8997202", "049a98762a29677da352405b27b3d910cb94eb3b", "7e916b0edd394d0fca76456af89f4ff7f7f65049", "0dd03338d20d2e8068fbac9f24899d45d443df38", "70dbcf426232f7a33c7e5ebdfbfb26fc8c467a46", "a894d7d58ffde625019a9ecf8267f5f1d1e5c341", "f3f826ce85d6dad25156b2d7550cedeb1a422f4c", "ee886e4adb70fbe3bdc6f3f6393598b3f02e8009", "6fce8fe45550eb72796704a919dad68dc44be44a", "ad4528ed5c84092fdbe9e0502163cf8d6e6141e7", "97442a720324a0bd092fb9235f72246dc8b345bc", "2276eaf76a658f96b5cf3eb25f3e1fda90f6b653");
    List<String> reported = new ArrayList<String>();
    for (CommitInfo c : commits) {
        System.out.println(c.getVersion() + " " + c.getBranches() + " " + c.getTags() + " " + c.getHeadNames() + "  " + c.getMountPoints());
        Assert.assertEquals(c.getBranches(), c.getHeadNames());
        reported.add(c.getVersion());
    }
    assertTrue(reported.containsAll(allCommits));
    System.out.println("actual submodules:");
    Set<String> submodules = new TreeSet<String>();
    for (CommitInfo commit : commits) {
        for (CommitMountPointInfo info : commit.getMountPoints()) {
            final String line = commit.getVersion() + ": " + info.getMountPath() + " => " + info.getMountRevision();
            submodules.add(line);
            System.out.println(line);
        }
    }
    List<String> expectedSubmodules = new ArrayList<String>(Arrays.asList("7253d358a2490321a1808a1c20561b4027d69f77: submodule-wihtout-entry => 293a6e0d110fdbeed9729d87945876a0c52da182", "7253d358a2490321a1808a1c20561b4027d69f77: submodule-with-dirs => ded023a236d184753f826e62ac16b1612060e9d0", "27de3d118ca320d3a8a08320ff05aa0567996590: submodule => 6d944ac86dd5a45265873ddaa60e7ec343c1c4bb", "39679cc440c83671fbf6ad8083d92517f9602300: submodule-wihtout-entry => 293a6e0d110fdbeed9729d87945876a0c52da182", "39679cc440c83671fbf6ad8083d92517f9602300: submodule-with-dirs => 42fd2819d05e5b2b733f0a20e9b8b918e6e62141", "9395143dd6c3e73abf9281be7a772c4d286e72a5: submodule-with-dirs => 42fd2819d05e5b2b733f0a20e9b8b918e6e62141", "039e7395725ad8d2a143fd44645a3fb72b001217: submodule-with-dirs => 42fd2819d05e5b2b733f0a20e9b8b918e6e62141", "777f79b3e89e63ac954fe0881470be3c72b8b0d4: submodule-with-dirs => 42fd2819d05e5b2b733f0a20e9b8b918e6e62141", "f61e30ce576e76bff877ddf1d00acf22c5c1b07a: submodule-on-tag => 09f4eb4218bcbea3e3fa07ed552e1d4e9a6ffda7", "6cf3cb6a87091d17466607858c699c35edf30d3b: submodule-wihtout-entry => 293a6e0d110fdbeed9729d87945876a0c52da182", "6cf3cb6a87091d17466607858c699c35edf30d3b: submodule-with-dirs => 42fd2819d05e5b2b733f0a20e9b8b918e6e62141", "e6b15b1f4741199857e2fa744eaadfe5a9d9aede: submodule-wihtout-entry => 293a6e0d110fdbeed9729d87945876a0c52da182", "92112555d9eb3e433eaa91fe32ec001ae8fe3c52: submodule-wihtout-entry => 6d944ac86dd5a45265873ddaa60e7ec343c1c4bb", "f5bdd3819df0358a43d9a8f94eaf96bb306e19fe: submodule-wihtout-entry => 6d944ac86dd5a45265873ddaa60e7ec343c1c4bb", "ce6044093939bb47283439d97a1c80f759669ff5: first-level-submodule => 2ffafea06c7a385a78092dbc5e8a5a6225574397", "d1a88fd33c516c1b607db75eb62244b2ea495c42: submodule => 6d944ac86dd5a45265873ddaa60e7ec343c1c4bb", "37c371a6db0acefc77e3be99d16a44413e746591: submodule => 293a6e0d110fdbeed9729d87945876a0c52da182", "b5d65401a4e8a09b80b8d73ca4392f1913e99ff5: submodule => 6d944ac86dd5a45265873ddaa60e7ec343c1c4bb"));
    Assert.assertTrue(submodules.containsAll(expectedSubmodules));
}
Also used : CommitMountPointInfo(jetbrains.vcs.api.CommitMountPointInfo) GitCommitsInfoBuilder(jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.GitCommitsInfoBuilder) GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) GitCommitsInfoBuilder(jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.GitCommitsInfoBuilder) CommitInfo(jetbrains.vcs.api.CommitInfo) GitFetchService(jetbrains.buildServer.buildTriggers.vcs.git.GitFetchService)

Example 4 with GitVcsSupport

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport in project teamcity-git by JetBrains.

the class GitCommitsInfoBuilderTest method test_r2_local.

@Test(enabled = false)
public void test_r2_local() throws VcsException {
    // /does not work for real repository: Fetcher call is mostly endless
    VcsRoot root = vcsRoot().withFetchUrl("E:\\Temp\\mock\\r2\\.git").withRepositoryPathOnServer("E:\\Temp\\mock\\r2\\.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)

Example 5 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_after_is_invalid_sha.

public void should_use_modification_revision_when_revision_after_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", null, invalidSHA);
    byte[] actual = git.getContentProvider().getContent(m, change, VcsChangeInfo.ContentType.AFTER_CHANGE, root);
    byte[] expected = "Test repository for teamcity.change 1\n".getBytes();
    assertEquals(expected, actual);
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)

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