use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class JGitListCommand method executeListCommand.
@Override
protected ListScmResult executeListCommand(ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
Git git = null;
try {
git = JGitUtils.openRepo(fileSet.getBasedir());
CredentialsProvider credentials = JGitUtils.prepareSession(getLogger(), git, (GitScmProviderRepository) repo);
List<ScmFile> list = new ArrayList<ScmFile>();
Collection<Ref> lsResult = git.lsRemote().setCredentialsProvider(credentials).call();
for (Ref ref : lsResult) {
getLogger().debug(ref.getObjectId().getName() + " " + ref.getTarget().getName());
list.add(new ScmFile(ref.getName(), ScmFileStatus.CHECKED_IN));
}
return new ListScmResult("JGit ls-remote", list);
} catch (Exception e) {
throw new ScmException("JGit ls-remote failure!", e);
} finally {
JGitUtils.closeRepo(git);
}
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class LocalListCommand method executeListCommand.
/**
* {@inheritDoc}
*/
protected ListScmResult executeListCommand(ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion version) throws ScmException {
if (version != null) {
throw new ScmException("The local scm doesn't support tags.");
}
LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;
File root = new File(repository.getRoot());
String module = repository.getModule();
File source = new File(root, module);
if (!root.exists()) {
throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ").");
}
if (!source.exists()) {
throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ").");
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Listing files of '" + source.getAbsolutePath() + "'.");
}
try {
if (fileSet.getFileList() == null || fileSet.getFileList().isEmpty()) {
return new LocalListScmResult(null, getFiles(source, source, recursive));
} else {
List<ScmFile> files = new ArrayList<ScmFile>();
Iterator<File> it = fileSet.getFileList().iterator();
while (it.hasNext()) {
File file = (File) it.next();
files.addAll(getFiles(source, new File(source, file.getPath()), recursive));
}
return new LocalListScmResult(null, files);
}
} catch (Exception e) {
return new ListScmResult(null, "The svn command failed.", e.getMessage(), false);
}
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class LocalMkdirCommandTckTest method testMkdirCommandMkdirUrl.
public void testMkdirCommandMkdirUrl() throws Exception {
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false);
assertResultIsSuccess(result);
ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
assertTrue("Directory should have been found.", listResult.isSuccess());
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class LocalMkdirCommandTckTest method testMkdirCommandDirAlreadyAdded.
public void testMkdirCommandDirAlreadyAdded() throws Exception {
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false);
assertResultIsSuccess(result);
ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
assertTrue("Directory should have been found.", listResult.isSuccess());
// add the directory again
result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false);
assertFalse(result.isSuccess());
printOutputError(result);
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class LocalScmProvider method list.
/**
* {@inheritDoc}
*/
protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
LocalListCommand command = new LocalListCommand();
command.setLogger(getLogger());
return (ListScmResult) command.execute(repository, fileSet, parameters);
}
Aggregations