Search in sources :

Example 31 with VcsRoot

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

the class TestConnectionTest method testConnection_should_not_be_blocked_by_long_fetch.

public void testConnection_should_not_be_blocked_by_long_fetch() throws Exception {
    PluginConfigBuilder config = pluginConfig().withDotBuildServerDir(myTempFiles.createTempDir()).setSeparateProcessForFetch(false);
    final Semaphore fetchStarted = new Semaphore(1);
    final Semaphore fetchCanFinish = new Semaphore(1);
    final GitVcsSupport git = gitSupport().withBeforeFetchHook(new Runnable() {

        public void run() {
            fetchStarted.release();
            fetchCanFinish.acquireUninterruptibly();
        }
    }).withPluginConfig(config).build();
    final VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).build();
    // don't allow fetch to start
    fetchStarted.acquireUninterruptibly();
    // don't allow fetch to finish
    fetchCanFinish.acquireUninterruptibly();
    Thread longFetch = new Thread(new Runnable() {

        public void run() {
            try {
                git.collectChanges(root, "2276eaf76a658f96b5cf3eb25f3e1fda90f6b653", "ad4528ed5c84092fdbe9e0502163cf8d6e6141e7", CheckoutRules.DEFAULT);
            } catch (VcsException e) {
                e.printStackTrace();
            }
        }
    });
    longFetch.start();
    Assert.assertTrue(fetchStarted.tryAcquire(10, TimeUnit.SECONDS));
    // test connection during long fetch
    git.testConnection(root);
    // allow fetch to finish
    fetchCanFinish.release();
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) Semaphore(java.util.concurrent.Semaphore) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 32 with VcsRoot

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

the class TransportFactoryTest method transport_for_anonymous_protocol_should_not_have_credentials.

@TestFor(issues = "TW-25087")
public void transport_for_anonymous_protocol_should_not_have_credentials() throws Exception {
    File tmp = myTempFiles.createTempDir();
    Repository r = new RepositoryBuilder().setBare().setGitDir(tmp).build();
    VcsRoot root = vcsRoot().withFetchUrl("git://some.org/repo.git").withAuthMethod(AuthenticationMethod.PASSWORD).withUsername("user").withPassword("pwd").build();
    AuthSettings authSettings = new AuthSettingsImpl(root, new URIishHelperImpl());
    TransportFactory factory = new TransportFactoryImpl(myConfigBuilder.build(), new EmptyVcsRootSshKeyManager());
    factory.createTransport(r, new URIishHelperImpl().createAuthURI(authSettings, "git://some.org/repo.git").get(), authSettings);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) RepositoryBuilder(org.eclipse.jgit.lib.RepositoryBuilder) GitTestUtil.getVcsRoot(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.getVcsRoot) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Example 33 with VcsRoot

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

the class LatestAcceptedRevisionTest method test_search_by_path.

public void test_search_by_path() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/br1", "d5a9a3c51fd53b1aec5e3746f521dc78355d7c78");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "d5a9a3c51fd53b1aec5e3746f521dc78355d7c78", Collections.emptySet());
    then(rev).isEqualTo("a4bc5909156143a5590adadb2c20eaf71f2a3f8f");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test"), "bb6ab65d23fa0ffbaa61d44c8241f127cf0f323f", Collections.emptySet());
    then(rev).isEqualTo("b265fd1608fe17f912a031312e1efc758c4e8a35");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "b265fd1608fe17f912a031312e1efc758c4e8a35", Collections.singleton("d5a9a3c51fd53b1aec5e3746f521dc78355d7c78"));
    then(rev).isNull();
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "b265fd1608fe17f912a031312e1efc758c4e8a35", Collections.singleton("a4bc5909156143a5590adadb2c20eaf71f2a3f8f"));
    then(rev).isEqualTo("a4bc5909156143a5590adadb2c20eaf71f2a3f8f");
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 34 with VcsRoot

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

the class LatestAcceptedRevisionTest method both_parents_of_merge_are_interesting_latest_parents_change_non_interesting_files.

public void both_parents_of_merge_are_interesting_latest_parents_change_non_interesting_files() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/br4", "ce92302a768ce0763e83aebf8c0e16e102c8d06b");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "ce92302a768ce0763e83aebf8c0e16e102c8d06b", Collections.emptySet());
    then(rev).isEqualTo("d036d012385a762568a474b57337b9cf398b96e0");
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 35 with VcsRoot

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

the class LatestAcceptedRevisionTest method test_start_and_stop_are_not_in_repository.

public void test_start_and_stop_are_not_in_repository() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test"), "94f6d9029650d88a96e7785d9bc672408bb6e076", Collections.singleton("e45f42c7cdcc2d3433e4542cca8f0e2c46d06489"));
    then(rev).isNull();
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) 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