use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class AuthSettingsTest method auth_uri_for_anonymous_protocol_should_not_have_user_and_password.
@TestFor(issues = "TW-25087")
public void auth_uri_for_anonymous_protocol_should_not_have_user_and_password() throws Exception {
VcsRoot root = vcsRoot().withFetchUrl("git://some.org/repo.git").withAuthMethod(AuthenticationMethod.PASSWORD).withUsername("user").withPassword("pwd").build();
AuthSettings authSettings = new AuthSettingsImpl(root, new URIishHelperImpl());
URIish authURI = new URIishHelperImpl().createAuthURI(authSettings, "git://some.org/repo.git").get();
assertNull(authURI.getUser());
assertNull(authURI.getPass());
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class SGitVcsRoot method getOrRefreshToken.
@Nullable
protected ExpiringAccessToken getOrRefreshToken(@NotNull String tokenId) {
VcsRoot vcsRoot = getOriginalRoot();
if (myTokenRefresher == null)
return null;
SVcsRoot parentRoot = vcsRoot instanceof SVcsRoot ? (SVcsRoot) vcsRoot : vcsRoot instanceof VcsRootInstance ? ((VcsRootInstance) vcsRoot).getParent() : null;
if (parentRoot == null) {
return myTokenRefresher.getRefreshableToken(vcsRoot.getExternalId(), tokenId);
} else {
return myTokenRefresher.getRefreshableToken(parentRoot.getProject(), tokenId);
}
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class AgentMirrorCleaner method getRunningBuildRepositories.
private Set<String> getRunningBuildRepositories(@NotNull DirectoryCleanersProviderContext context) {
Set<String> repositories = new HashSet<String>();
for (VcsRootEntry entry : context.getRunningBuild().getVcsRootEntries()) {
VcsRoot root = entry.getVcsRoot();
if (!Constants.VCS_NAME.equals(root.getVcsName()))
continue;
try {
GitVcsRoot gitRoot = new AgentGitVcsRoot(myMirrorManager, root, myTokenStorage);
String repositoryUrl = gitRoot.getRepositoryFetchURL().toString();
LOG.debug("Repository " + repositoryUrl + " is used in the build, its mirror won't be cleaned");
addRepositoryWithSubmodules(repositories, gitRoot.getRepositoryFetchURL().toString());
} catch (VcsException e) {
LOG.warn("Error while creating git root " + root.getName() + ". If the root has a mirror on agent, the mirror might be cleaned", e);
}
}
return repositories;
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class ScriptGenTest method check_escaping.
@TestFor(issues = "TW-40688")
@Test(dataProvider = "passwords")
public void check_escaping(@NotNull String password) throws Exception {
VcsRoot root = createRootWithPassword(password);
GeneralCommandLine cmd = new GeneralCommandLine();
cmd.setExePath(createGenerator().generateAskPass(new AuthSettingsImpl(root, new URIishHelperImpl())).getCanonicalPath());
ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, null);
assertEquals(password, trimNewLines(result.getStdout()));
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class SubmoduleErrorsTest method cannot_fetch_submodule.
public void cannot_fetch_submodule() throws Exception {
String submodulePath = "sub";
String wrongSubmoduleUrl = new File(myMainRepo.getParent(), "sub2").getCanonicalPath();
String brokenCommit = "9c328ea69b41ad2bfa162c72fd52cf87376225b7";
VcsRoot root = vcsRoot().withFetchUrl(myMainRepoUrl).withSubmodulePolicy(SubmodulesCheckoutPolicy.CHECKOUT).build();
try {
myGitSupport.collectChanges(root, "6dbc05799659295e480894e367f4159d57fba30d", brokenCommit, CheckoutRules.DEFAULT);
fail("Should fail due to incorrect submodule url");
} catch (VcsException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Cannot fetch the '" + wrongSubmoduleUrl + "' repository used as a submodule at the '" + submodulePath + "' path in the '" + myMainRepoUrl + "' repository in the " + brokenCommit + " commit"));
}
}
Aggregations