Search in sources :

Example 26 with VcsRoot

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

the class GitLabelingSupportTest method fail_labeling_when_heuristics_fails.

public void fail_labeling_when_heuristics_fails() throws Exception {
    myConfig.setUsePackHeuristic(true);
    myConfig.setFailLabelingWhenPackHeuristicsFail(true);
    GitVcsSupport git = buildGit();
    File remoteRepoDir = getRemoteRepositoryDir("repo_for_fetch.2");
    VcsRoot root = vcsRoot().withFetchUrl(remoteRepoDir).build();
    makeCloneOnServer(git, root);
    // erase commit in the remote repository
    FileUtil.delete(remoteRepoDir);
    remoteRepoDir.mkdirs();
    FileUtil.copyDir(getRemoteRepositoryDir("repo_for_fetch.1"), remoteRepoDir);
    try {
        // label erased commit
        String erasedCommit = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
        git.getLabelingSupport().label("label", erasedCommit, root, CheckoutRules.DEFAULT);
        fail("Should fail labeling since heuristics fails");
    } catch (VcsException e) {
        assertTrue(true);
    }
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) VcsException(jetbrains.buildServer.vcs.VcsException) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) File(java.io.File)

Example 27 with VcsRoot

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

the class GitLabelingSupportTest method should_push_all_objects_missing_in_remote_repository.

@Test(dataProvider = "true,false")
public void should_push_all_objects_missing_in_remote_repository(boolean usePackHeuristics) throws Exception {
    myConfig.setUsePackHeuristic(usePackHeuristics);
    GitVcsSupport git = buildGit();
    File remoteRepoDir = getRemoteRepositoryDir("repo_for_fetch.2");
    VcsRoot root = vcsRoot().withFetchUrl(remoteRepoDir).build();
    makeCloneOnServer(git, root);
    // erase commit in the remote repository
    FileUtil.delete(remoteRepoDir);
    remoteRepoDir.mkdirs();
    FileUtil.copyDir(getRemoteRepositoryDir("repo_for_fetch.1"), remoteRepoDir);
    // label erased commit
    String erasedCommit = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
    git.getLabelingSupport().label("label", erasedCommit, root, CheckoutRules.DEFAULT);
    // erased commit should appear in the remote repository
    Repository r = new RepositoryBuilder().setGitDir(remoteRepoDir).build();
    RevWalk walk = new RevWalk(r);
    try {
        walk.parseCommit(ObjectId.fromString(erasedCommit));
    } catch (MissingObjectException e) {
        fail("Not all objects were pushed, labeled commit " + erasedCommit + " is missing");
    } finally {
        walk.close();
        r.close();
    }
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) RevWalk(org.eclipse.jgit.revwalk.RevWalk) File(java.io.File) MissingObjectException(org.eclipse.jgit.errors.MissingObjectException) Test(org.testng.annotations.Test)

Example 28 with VcsRoot

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

the class GitPatchTest method submodules_and_checkout_rules4.

@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules4(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = getRoot("sub-submodule", true);
    checkPatch(root, "submodules_and_checkout_rules4", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("+:first-level-submodule/sub-sub/file.txt"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 29 with VcsRoot

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

the class CleanerTest method nonInplaceGc.

public void nonInplaceGc() throws Exception {
    myConfigBuilder.setRunNativeGC(true);
    myConfigBuilder.setRunInPlaceGc(false);
    initCleanup();
    VcsRoot root = GitTestUtil.getVcsRoot();
    // clone repository
    mySupport.collectChanges(root, "70dbcf426232f7a33c7e5ebdfbfb26fc8c467a46", "a894d7d58ffde625019a9ecf8267f5f1d1e5c341", CheckoutRules.DEFAULT);
    File repositoryDir = getRepositoryDir(root);
    // create more than 50 packs to trigger gc:
    File packDir = new File(repositoryDir, "objects/pack");
    final File[] packs = FileUtil.listFiles(packDir, (dir, name) -> name.startsWith("pack-") && name.endsWith(".pack"));
    assertTrue(packs.length > 0);
    File pack = packs[0];
    File idx = new File(packDir, StringUtil.replace(pack.getName(), ".pack", ".idx"));
    for (int i = 10; i <= 60; i++) {
        final File newPack = new File(packDir, "pack-" + i + "63fffad1c368b0a79f9a196ee098e303fc0c29.pack");
        final File newIdx = new File(packDir, "pack-" + i + "63fffad1c368b0a79f9a196ee098e303fc0c29.idx");
        if (newPack.isFile() || newIdx.isFile())
            continue;
        FileUtil.copy(pack, newPack);
        FileUtil.copy(idx, newIdx);
    }
    FileRepository db = (FileRepository) new RepositoryBuilder().setGitDir(repositoryDir).build();
    then(db.getObjectDatabase().getPacks().size() > 50).isTrue();
    myCleanup.run();
    db = (FileRepository) new RepositoryBuilder().setGitDir(repositoryDir).build();
    then(db.getObjectDatabase().getPacks().size()).isEqualTo(1);
}
Also used : FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) RepositoryBuilder(org.eclipse.jgit.lib.RepositoryBuilder) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) File(java.io.File)

Example 30 with VcsRoot

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

the class TestConnectionTest method should_failed_when_branch_not_found.

public void should_failed_when_branch_not_found() throws Exception {
    try {
        VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("no-such-branch").build();
        myGit.testConnection(root);
        fail("Test connection should fail for unknown branch");
    } catch (VcsException ex) {
        assertTrue(true);
    }
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Aggregations

VcsRoot (jetbrains.buildServer.vcs.VcsRoot)59 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)25 TestFor (jetbrains.buildServer.util.TestFor)17 Test (org.testng.annotations.Test)16 GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)15 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)10 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)9 File (java.io.File)8 VcsException (jetbrains.buildServer.vcs.VcsException)8 URIish (org.eclipse.jgit.transport.URIish)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)3 NotNull (org.jetbrains.annotations.NotNull)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)2 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)2 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)2 TeamCitySshKey (jetbrains.buildServer.ssh.TeamCitySshKey)2 BulkPatchBuilder (jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder)2 RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)2