use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class NativeGitCommands method lsRemote.
@NotNull
@Override
public Map<String, Ref> lsRemote(@NotNull Repository db, @NotNull GitVcsRoot gitRoot, @NotNull FetchSettings settings) throws VcsException {
final Context ctx = new ContextImpl(gitRoot, myConfig, myGitDetector.detectGit(), settings.getProgress());
final GitFacadeImpl gitFacade = new GitFacadeImpl(db.getDirectory(), ctx);
gitFacade.setSshKeyManager(mySshKeyManager);
final jetbrains.buildServer.buildTriggers.vcs.git.command.LsRemoteCommand lsRemote = gitFacade.lsRemote().peelRefs().setAuthSettings(gitRoot.getAuthSettings()).setUseNativeSsh(true).setTimeout(myConfig.getRepositoryStateTimeoutSeconds()).setRetryAttempts(myConfig.getConnectionRetryAttempts()).trace(myConfig.getGitTraceEnv());
return executeCommand(ctx, "ls-remote", LogUtil.describe(gitRoot), () -> {
return lsRemote.call().stream().collect(Collectors.toMap(Ref::getName, ref -> ref));
});
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class CommitLoaderImpl method getRefSpecForCurrentState.
@NotNull
private Collection<RefSpec> getRefSpecForCurrentState(@NotNull OperationContext context, @NotNull Collection<RefCommit> revisions, @NotNull Collection<String> remoteRefs) throws VcsException {
final Set<RefSpec> result = new HashSet<>();
final Set<String> missingTips = new HashSet<>();
for (RefCommit r : revisions) {
final String ref = r.getRef();
final boolean existsRemotely = remoteRefs.contains(ref);
if (existsRemotely) {
result.add(new RefSpec(ref + ":" + ref).setForceUpdate(true));
continue;
}
if (r.isRefTip()) {
missingTips.add(ref);
} else {
LOG.debug(String.format(REF_MISSING_FORMAT, ref) + " for " + context.getGitRoot().debugInfo());
}
}
final int remotelyMissingRefsNum = missingTips.size();
if (remotelyMissingRefsNum > 0) {
final String message = remotelyMissingRefsNum == 1 ? String.format(REF_MISSING_FORMAT, missingTips.iterator().next()) : String.format(REFS_MISSING_FORMAT, StringUtil.join(", ", missingTips));
final VcsException exception = new VcsException(message);
exception.setRecoverable(context.getPluginConfig().treatMissingBranchTipAsRecoverableError());
throw exception;
}
return result;
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class FetcherProperties method getPropertiesFile.
@NotNull
public File getPropertiesFile() throws VcsException {
try {
File props = FileUtil.createTempFile("git", "props");
GitServerUtil.writeAsProperties(props, myConfig.getFetcherProperties());
return props;
} catch (IOException e) {
throw new VcsException("Cannot create properties file for git fetch process: " + e.getMessage(), e);
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class TestConnectionTest method should_failed_when_branch_not_found.
public void should_failed_when_branch_not_found() throws Exception {
try {
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("no-such-branch").build();
myGit.testConnection(root);
fail("Test connection should fail for unknown branch");
} catch (VcsException ex) {
assertTrue(true);
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class TestConnectionTest method test_not_existing_local_repository.
@TestFor(issues = "TW-9933")
public void test_not_existing_local_repository() throws Exception {
File notExisting = new File(myTempFiles.createTempDir(), "not-existing");
String url = GitUtils.toURL(notExisting);
VcsRootImpl root = vcsRoot().withFetchUrl(url).build();
try {
myGit.testConnection(root);
fail("Should throw an exception for not-existing repository");
} catch (VcsException e) {
TeamCityAsserts.assertContainsAny(e.getMessage(), "Cannot access the '" + url + "' repository", "Please make sure you have the correct access rights and the repository exists");
assertFalse(e.getMessage().endsWith("\n"));
}
}
Aggregations