use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class HttpUrlWithUsernameTest method should_include_username_into_url_when_asked.
@Test(dataProvider = "mirrorModes")
public void should_include_username_into_url_when_asked(@NotNull MirrorMode mirrorMode) throws Exception {
// need that in order to be able to disable new logic in case of any problems
File repo = copyRepository(myTempFiles, dataFile("repo_for_fetch.1"), "repo.git");
startGitServer(repo);
VcsRootImpl root = createRoot();
AgentRunningBuild build = createBuild(configParams(mirrorMode, PluginConfigImpl.EXCLUDE_USERNAME_FROM_HTTP_URL, "false"));
checkout(root, build, "add81050184d3c818560bdd8839f50024c188586");
if (mirrorMode != MirrorMode.DISABLED) {
StoredConfig config = getMirrorConfig(root);
then(config.getString("remote", "origin", "url")).contains(USER + "@");
}
StoredConfig config = getWorkingDirConfig();
then(config.getString("remote", "origin", "url")).contains(USER + "@");
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl 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");
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl 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");
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class GitUrlSupportTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
ServerPaths paths = new ServerPaths(myTempFiles.createTempDir().getAbsolutePath());
PluginConfig config = new PluginConfigBuilder(paths).build();
myMirrorManager = new MirrorManagerImpl(config, new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl());
myProjectMock = mock(SProject.class);
final Mock pmMock = mock(ProjectManager.class);
final SProject project = (SProject) myProjectMock.proxy();
pmMock.stubs().method("findProjectById").will(returnValue(project));
ProjectManager pm = (ProjectManager) pmMock.proxy();
final Mock sshMock = mock(ServerSshKeyManager.class);
sshMock.stubs().method("getKeys").with(eq(project)).will(returnValue(myTestKeys));
ServerSshKeyManager ssh = (ServerSshKeyManager) sshMock.proxy();
Mock epMock = mock(ExtensionsProvider.class);
epMock.stubs().method("getExtensions").with(eq(ServerSshKeyManager.class)).will(returnValue(Collections.singleton(ssh)));
myGitVcsSupport = gitSupport().withServerPaths(paths).withTestConnectionSupport(vcsRoot -> {
if (myTestConnectionMocked != null && myTestConnectionMocked)
return null;
return myGitVcsSupport.testConnection(vcsRoot);
}).build();
myUrlSupport = new GitUrlSupport(myGitVcsSupport) {
@NotNull
@Override
protected VcsRoot createDummyRoot(@NotNull final Map<String, String> props, @Nullable final SProject curProject) {
return new VcsRootImpl(-1, Constants.VCS_NAME, props);
}
};
myUrlSupport.setProjectManager(pm);
myUrlSupport.setExtensionsProvider((ExtensionsProvider) epMock.proxy());
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method short_lived_agent_auto_clone_existing_mirror.
@TestFor(issues = "TW-71416")
public void short_lived_agent_auto_clone_existing_mirror() throws Exception {
final File remote = dataFile("repo_for_shallow_fetch.git");
final VcsRootImpl root1 = createRoot(remote, "refs/heads/main");
root1.addProperty(Constants.CHECKOUT_POLICY, AgentCheckoutPolicy.USE_MIRRORS.name());
myVcsSupport.updateSources(root1, new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myTempFiles.createTempDir(), myBuild, false);
final File mirror = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(remote));
// mirror initialized
assertFalse(FileUtil.isEmptyDir(mirror));
myBuild.getAgentConfiguration().addConfigurationParameter(AgentMiscConstants.IS_EPHEMERAL_AGENT_PROP, "true");
final File testFile = new File(myCheckoutDir, "test_file");
final File shallowMarker = new File(myCheckoutDir, ".git/shallow");
final VcsRootImpl root2 = createRoot(remote, "refs/heads/main");
root2.addProperty(Constants.CHECKOUT_POLICY, AgentCheckoutPolicy.AUTO.name());
myVcsSupport.updateSources(root2, new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, myBuild, false);
assertFalse(shallowMarker.exists());
}
Aggregations