use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class SvnCheckInConsumer method parseLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected void parseLine(String line) {
String file;
if (line.startsWith(COMMITTED_REVISION_TOKEN)) {
String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1);
revision = parseInt(revisionString);
return;
} else if (line.startsWith(SENDING_TOKEN)) {
file = line.substring(SENDING_TOKEN.length());
} else if (line.startsWith(ADDING_TOKEN)) {
file = line.substring(ADDING_TOKEN.length());
} else if (line.startsWith(ADDING_BIN_TOKEN)) {
file = line.substring(ADDING_BIN_TOKEN.length());
} else if (line.startsWith(DELETING_TOKEN)) {
file = line.substring(DELETING_TOKEN.length());
} else if (line.startsWith(TRANSMITTING_TOKEN)) {
// ignore
return;
} else {
if (logger.isInfoEnabled()) {
logger.info("Unknown line: '" + line + "'");
}
return;
}
addFile(new ScmFile(file, ScmFileStatus.CHECKED_IN));
}
use of org.apache.maven.scm.ScmFile 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.ScmFile in project maven-scm by apache.
the class JGitStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
Git git = null;
try {
git = JGitUtils.openRepo(fileSet.getBasedir());
Status status = git.status().call();
List<ScmFile> changedFiles = getFileStati(status);
return new StatusScmResult("JGit status", changedFiles);
} catch (Exception e) {
throw new ScmException("JGit status failure!", e);
} finally {
JGitUtils.closeRepo(git);
}
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class SvnDiffConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (line.startsWith(INDEX_TOKEN)) {
// start a new file
currentFile = line.substring(INDEX_TOKEN.length());
changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED));
currentDifference = new StringBuilder();
differences.put(currentFile, currentDifference);
patch.append(line).append("\n");
return;
}
if (currentFile == null) {
if (logger.isWarnEnabled()) {
logger.warn("Unparseable line: '" + line + "'");
}
patch.append(line).append("\n");
return;
}
if (line.startsWith(FILE_SEPARATOR_TOKEN)) {
// skip
patch.append(line).append("\n");
} else if (line.startsWith(START_REVISION_TOKEN)) {
// skip, though could parse to verify filename, start revision
patch.append(line).append("\n");
} else if (line.startsWith(END_REVISION_TOKEN)) {
// skip, though could parse to verify filename, end revision
patch.append(line).append("\n");
} else if (line.startsWith(ADDED_LINE_TOKEN) || line.startsWith(REMOVED_LINE_TOKEN) || line.startsWith(UNCHANGED_LINE_TOKEN) || line.startsWith(CHANGE_SEPARATOR_TOKEN) || line.equals(NO_NEWLINE_TOKEN)) {
// add to buffer
currentDifference.append(line).append("\n");
patch.append(line).append("\n");
} else {
if (logger.isWarnEnabled()) {
logger.warn("Unparseable line: '" + line + "'");
}
patch.append(line).append("\n");
// skip to next file
currentFile = null;
currentDifference = null;
}
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class LocalListCommand method getFiles.
private List<ScmFile> getFiles(File source, File directory, boolean recursive) throws Exception {
if (!directory.exists()) {
throw new Exception("Directory '" + directory.getAbsolutePath() + "' doesn't exist.");
}
List<ScmFile> files = new ArrayList<ScmFile>();
File[] filesArray = directory.listFiles();
if (filesArray != null) {
for (int i = 0; i < filesArray.length; i++) {
File f = filesArray[i];
String path = f.getAbsolutePath().substring(source.getAbsolutePath().length());
path = StringUtils.replace(path, "\\", "/");
path = StringUtils.replace(path, "/./", "/");
files.add(new ScmFile(path, ScmFileStatus.CHECKED_IN));
if (f.isDirectory() && recursive) {
files.addAll(getFiles(source, f, recursive));
}
}
}
return files;
}
Aggregations