Search in sources :

Example 6 with RepositoryStateData

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

the class GitLabelingSupportTest method makeCloneOnServer.

private void makeCloneOnServer(@NotNull GitVcsSupport git, @NotNull VcsRoot root) throws VcsException {
    RepositoryStateData currentState = git.getCurrentState(root);
    String unknownRevision = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    String defaultBranchName = currentState.getDefaultBranchName();
    git.collectChanges(root, unknownRevision, currentState.getBranchRevisions().get(defaultBranchName), CheckoutRules.DEFAULT);
}
Also used : RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData)

Example 7 with RepositoryStateData

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

the class GitPerformanceTests method toCleanCheckoutTest.

@Test
public void toCleanCheckoutTest() throws Exception {
    final VcsRootImpl root = VcsRootBuilder.vcsRoot().withFetchUrl("E:\\Work\\idea-ultimate").build();
    final ServerPaths sp = new ServerPaths(createTempDir().getPath());
    final GitSupportBuilder builder = GitSupportBuilder.gitSupport().withServerPaths(sp).withPluginConfig(new PluginConfigBuilder(sp).build());
    GitVcsSupport support = builder.build();
    RepositoryStateData s = support.getCurrentState(root);
    final String state = s.getBranchRevisions().get(s.getDefaultBranchName());
    System.out.println("Current state: " + state);
    final long startTime = new Date().getTime();
    System.out.println("Fetching repository...");
    // make sure repository is cloned
    final OperationContext ctx = support.createContext(root, "fetch");
    try {
        builder.getCommitLoader().loadCommit(ctx, ctx.getGitRoot(), state);
    } finally {
        ctx.close();
    }
    final long totalTime = new Date().getTime() - startTime;
    System.out.println("Clone time: " + totalTime + "ms");
    runCleanCheckout(root, support, state);
    // some older state
    runCleanCheckout(root, support, "395c1639ee346816048b1b74cec83ab4dd162451");
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 8 with RepositoryStateData

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

the class GitPerformanceTests method incrementalIntellijFetch.

@Test
public // @Test(invocationCount = 100)
void incrementalIntellijFetch() throws Exception {
    final VcsRootImpl root = VcsRootBuilder.vcsRoot().withBranchSpec("+:refs/heads/*").withFetchUrl("ssh://git@git.jetbrains.team/intellij.git").withAuthMethod(AuthenticationMethod.PRIVATE_KEY_DEFAULT).build();
    final ServerPaths sp = new ServerPaths("/Users/victory/Tests/server_paths");
    final ServerPluginConfig config = new PluginConfigBuilder(sp).setSeparateProcessForFetch(true).build();
    final GitSupportBuilder builder = GitSupportBuilder.gitSupport().withServerPaths(sp).withPluginConfig(config).withFetchCommand(new NativeGitCommands(config, () -> new GitExec("git", new GitVersion(2, 34, 0)), new VcsRootSshKeyManager() {

        @Nullable
        @Override
        public TeamCitySshKey getKey(@NotNull VcsRoot root) {
            return null;
        }
    }));
    GitVcsSupport support = builder.build();
    final RepositoryStateData currentState = support.getCurrentState(root);
    final long startTime = new Date().getTime();
    System.out.println("Fetching repository...");
    final OperationContext ctx = support.createContext(root, "fetch");
    try {
        support.getCollectChangesPolicy().ensureRepositoryStateLoadedFor(ctx, currentState, true);
    } finally {
        ctx.close();
    }
    final long totalTime = new Date().getTime() - startTime;
    System.out.println("Fetch time: " + totalTime + "ms");
}
Also used : NativeGitCommands(jetbrains.buildServer.buildTriggers.vcs.git.command.NativeGitCommands) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) NotNull(org.jetbrains.annotations.NotNull) Date(java.util.Date) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData) VcsRootSshKeyManager(jetbrains.buildServer.ssh.VcsRootSshKeyManager) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) Test(org.testng.annotations.Test)

Aggregations

RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)8 Date (java.util.Date)2 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)2 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)2 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 NotNull (org.jetbrains.annotations.NotNull)2 Test (org.testng.annotations.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 CommitLoader (jetbrains.buildServer.buildTriggers.vcs.git.CommitLoader)1 OperationContext (jetbrains.buildServer.buildTriggers.vcs.git.OperationContext)1 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)1 NativeGitCommands (jetbrains.buildServer.buildTriggers.vcs.git.command.NativeGitCommands)1 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)1 VcsRootSshKeyManager (jetbrains.buildServer.ssh.VcsRootSshKeyManager)1 TestFor (jetbrains.buildServer.util.TestFor)1 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 VcsRootEntry (jetbrains.buildServer.vcs.VcsRootEntry)1