use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method list.
/**
* List remote subversion directory.
*
* @param request
* the request
*
* @return the response containing target children
*/
public ListResponse list(final ListRequest request) throws ApiException {
final List<String> args = defaultArgs();
args.add("list");
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(request.getTargetPath()), request.getUsername(), request.getPassword());
return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrorOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method commit.
/**
* Perform an "svn commit" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws SubversionException
* if there is a Subversion issue
*/
public CLIOutputWithRevisionResponse commit(final CommitRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
// Flags
addFlag(cliArgs, "--keep-changelists", request.isKeepChangeLists());
addFlag(cliArgs, "--no-unlock", request.isKeepLocks());
// Command Name
cliArgs.add("commit");
// Command Arguments
cliArgs.add("-m");
cliArgs.add(request.getMessage());
final CommandLineResult result = runCommand(null, cliArgs, projectPath, addWorkingCopyPathIfNecessary(request.getPaths()));
return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class).withCommand(result.getCommandLine().toString()).withRevision(SubversionUtils.getCommitRevision(result.getStdout())).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method getRevisions.
public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> uArgs = defaultArgs();
addOption(uArgs, "--revision", request.getRevisionRange());
uArgs.add("log");
final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
final GetRevisionsResponse response = DtoFactory.getInstance().createDto(GetRevisionsResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
if (result.getExitCode() == 0) {
List<String> revisions = result.getStdout().parallelStream().filter(line -> line.split("\\|").length == 4).map(line -> line.split("\\|")[0].trim()).collect(Collectors.toList());
response.withRevisions(revisions);
}
return response;
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method listTags.
/**
* Returns list of the tags of the project.
*
* @param request
* the request
*
* @see #list(ListRequest)
* @see #info(InfoRequest)
*/
public ListResponse listTags(final ListRequest request) throws ApiException {
InfoResponse info = info(newDto(InfoRequest.class).withProjectPath(request.getProjectPath()).withTarget(".").withPassword(request.getPassword()).withUsername(request.getUsername()));
final List<String> args = defaultArgs();
args.add("list");
String repositoryRoot = getRepositoryRoot(info.getOutput());
String projectRelativeUrl = getRelativeUrl(info.getOutput());
String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl);
String branchesPath = projectUri == null ? "^/tags" : (projectUri + "/tags");
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(branchesPath), request.getUsername(), request.getPassword());
return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout().stream().filter(s -> s.endsWith("/")).map(s -> s.substring(0, s.length() - 1)).collect(Collectors.toList())).withErrorOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method listBranches.
/**
* Returns list of the branches of the project.
*
* @param request
* the request
*
* @see #list(ListRequest)
* @see #info(InfoRequest)
*/
public ListResponse listBranches(final ListRequest request) throws ApiException {
InfoResponse info = info(newDto(InfoRequest.class).withProjectPath(request.getProjectPath()).withTarget(".").withPassword(request.getPassword()).withUsername(request.getUsername()));
final List<String> args = defaultArgs();
args.add("list");
String repositoryRoot = getRepositoryRoot(info.getOutput());
String projectRelativeUrl = getRelativeUrl(info.getOutput());
String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl);
String path = projectUri == null ? "^/branches" : (projectUri + "/branches");
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(path), request.getUsername(), request.getPassword());
return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout().stream().filter(s -> s.endsWith("/")).map(s -> s.substring(0, s.length() - 1)).collect(Collectors.toList())).withErrorOutput(result.getStderr());
}
Aggregations