Search in sources :

Example 21 with GitVcsSupport

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

the class LatestAcceptedRevisionTest method test_start_and_stop_are_the_same.

public void test_start_and_stop_are_the_same() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/master", "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test"), "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf", Collections.singleton("bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf"));
    then(rev).isNull();
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 22 with GitVcsSupport

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

the class GitPatchTest method checkPatch.

private void checkPatch(@NotNull VcsRoot root, String name, @Nullable String fromVersion, @NotNull String toVersion, @NotNull CheckoutRules rules) throws IOException, VcsException {
    setName(name);
    GitVcsSupport support = getSupport();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PatchBuilderImpl builder = new PatchBuilderImpl(output);
    support.buildPatch(root, fromVersion, toVersion, builder, rules);
    builder.close();
    checkPatchResult(output.toByteArray());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) PatchBuilderImpl(jetbrains.buildServer.vcs.patches.PatchBuilderImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 23 with GitVcsSupport

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

the class GitPatchTest method build_patch_several_roots.

@Test(dataProvider = "patchInSeparateProcess")
public void build_patch_several_roots(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    // A build configuration can have several VCS roots, TeamCity builds patches in them one by one
    // in unspecified order and then combines them into a single patch. That means a patch for
    // individual VCS root should never delete the root directory, because this action could delete
    // sources of another VCS root. Also patches should not contain an 'EXIT' command, otherwise
    // when agent applies a combined patch it will stop after first 'EXIT'.
    // patch8 is combination of patch1 and patch6
    setName("patch8");
    // patch1
    GitVcsSupport support = getSupport();
    VcsRoot root1 = getRoot("patch-tests", false);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PatchBuilderImpl builder = new PatchBuilderImpl(output);
    support.buildPatch(root1, null, "0dd03338d20d2e8068fbac9f24899d45d443df38", builder, CheckoutRules.DEFAULT);
    // patch6
    VcsRoot root2 = getRoot("rename-test", false);
    // pass an unknown fromRevision 'a...a' to ensure we don't remove the root dir if the fromRevision is not found
    support.buildPatch(root2, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "2eed4ae6732536f76a65136a606f635e8ada63b9", builder, CheckoutRules.DEFAULT);
    builder.close();
    checkPatchResult(output.toByteArray());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) PatchBuilderImpl(jetbrains.buildServer.vcs.patches.PatchBuilderImpl) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 24 with GitVcsSupport

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

the class GitPatchTest method checkPatch.

private void checkPatch(String name, @NotNull String branchName, @Nullable String fromVersion, @NotNull String toVersion, boolean enableSubmodules) throws IOException, VcsException {
    setName(name);
    GitVcsSupport support = getSupport();
    VcsRoot root = getRoot(branchName, enableSubmodules);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PatchBuilderImpl builder = new PatchBuilderImpl(output);
    support.buildPatch(root, fromVersion, toVersion, builder, CheckoutRules.DEFAULT);
    builder.close();
    checkPatchResult(output.toByteArray());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) PatchBuilderImpl(jetbrains.buildServer.vcs.patches.PatchBuilderImpl) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 25 with GitVcsSupport

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

the class ContentProviderTest method should_throw_exception_for_unknown_path.

@Test(expectedExceptions = VcsFileNotFoundException.class)
public void should_throw_exception_for_unknown_path() throws Exception {
    GitVcsSupport git = createGit();
    VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("version-test").build();
    String version = getDefaultBranchRevision(git, root);
    git.getContentProvider().getContent("unknown file path", root, version);
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) 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