use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class CleanCommandImpl method handleLongFileNames.
private void handleLongFileNames(@NotNull File rootDir, @NotNull VcsException originalError) throws VcsException {
List<String> files = new ArrayList<String>();
FileUtil.listFilesRecursively(rootDir, "", true, Integer.MAX_VALUE, new Predicate<File>() {
public boolean apply(File f) {
return true;
}
}, files);
int targetDirLength = rootDir.getAbsolutePath().length();
List<String> longFileNames = new ArrayList<String>();
for (String f : files) {
if (targetDirLength + 1 + f.length() >= 256)
longFileNames.add(f);
}
if (longFileNames.isEmpty()) {
Loggers.VCS.info("No files with long names found");
throw originalError;
} else {
Loggers.VCS.info(longFileNames.size() + " files with long names found:");
for (String f : longFileNames) {
Loggers.VCS.info(f);
}
Loggers.VCS.info("Try removing files with long names manually");
}
Repository repository = null;
try {
repository = new RepositoryBuilder().setWorkTree(rootDir).build();
WorkingDirStatus status = getWorkingDirStatus(repository);
Set<String> untracked = status.getUntracked();
for (String f : longFileNames) {
if (untracked.contains(f) || status.isIgnored(f)) {
FileUtil.delete(new File(rootDir, f));
Loggers.VCS.info(f + " is removed");
} else {
Loggers.VCS.info("The file " + f + " is tracked, don't remove it");
}
}
} catch (Exception e1) {
Loggers.VCS.error("Error while cleaning files with long names", e1);
} finally {
if (repository != null)
repository.close();
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class UpdaterWithAlternates method setupAlternates.
private void setupAlternates(@NotNull File gitDir, @NotNull File mirrorDir) throws VcsException {
if (!gitDir.exists())
throw new IllegalStateException(gitDir.getAbsolutePath() + " doesn't exist");
File objectsInfo = new File(new File(gitDir, "objects"), "info");
objectsInfo.mkdirs();
File alternates = new File(objectsInfo, "alternates");
try {
FileUtil.writeFileAndReportErrors(alternates, getAlternatePath(gitDir, mirrorDir));
copyRefs(gitDir, mirrorDir);
} catch (IOException e) {
LOG.warn("Error while configuring alternates at " + alternates.getAbsoluteFile(), e);
throw new VcsException(e);
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class TestConnectionTest method testConnection_should_validate_branchSpec.
public void testConnection_should_validate_branchSpec() throws Exception {
VcsRootImpl root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("master").withBranchSpec("+:/refs/heads/*").build();
try {
myGit.testConnection(root);
fail("Test connection should validate branchSpec");
} catch (VcsException e) {
assertTrue(e.getMessage().contains("pattern should not start with /"));
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class TestConnectionTest method testConnection_should_throw_exception_for_anonymous_git_url_with_username.
public void testConnection_should_throw_exception_for_anonymous_git_url_with_username() throws Exception {
ServerPluginConfig config = pluginConfig().withDotBuildServerDir(myTempFiles.createTempDir()).setIdleTimeoutSeconds(2).setFetchTimeout(2).setCurrentStateTimeoutSeconds(2).build();
myGit = gitSupport().withServerPaths(myPaths).withPluginConfig(config).build();
String url = "git://git@some.org/repository";
VcsRootImpl root = vcsRoot().withFetchUrl(url).build();
try {
myGit.testConnection(root);
fail("should fail, because native git fails for such url");
} catch (VcsException e) {
assertTrue(e.getMessage().contains("Incorrect url " + url + ": anonymous git url should not contain a username"));
}
// that means old roots that have such urls and use server-side checkout will still work
try {
myGit.collectChanges(root, "f3f826ce85d6dad25156b2d7550cedeb1a422f4c", "ce6044093939bb47283439d97a1c80f759669ff5", CheckoutRules.DEFAULT);
fail("should fail, because no such root exists");
} catch (VcsException e) {
assertFalse(e.getMessage().contains("Incorrect url " + url + ": anonymous git url should not contain a username"));
}
}
use of jetbrains.buildServer.vcs.VcsException 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