try {
FileUtils.copyDirectory(JenkinsFilesHelper.buildFileFromPathRelativeToHudsonRoot(pathRelativeToJenkinsRoot.getPath()),
fileTranslatedInScm);
} catch (IOException e) {
throw new LoggableException("Error while copying file hierarchy to SCM checkouted directory", FileUtils.class, "copyDirectory", e);
}
updatedFiles.addAll(scmManipulator.addFile(scmRoot, firstNonExistingParentScmPath));
}
} else {
// We should remember if file in scm existed or not before any manipulation,
// especially writing content
boolean fileTranslatedInScmInitiallyExists = fileTranslatedInScm.exists();
boolean fileContentModified = writeScmContentOnlyIfItDiffers(pathRelativeToJenkinsRoot, content, fileTranslatedInScm);
if(fileTranslatedInScmInitiallyExists){
if(fileContentModified){
// No need to call scmManipulator.addFile() if fileTranslatedInScm already existed
updatedFiles.add(fileTranslatedInScm);
}
} else {
updatedFiles.addAll(scmManipulator.addFile(scmRoot, pathRelativeToJenkinsRoot.getPath()));
}
}
}
for(Path path : commit.getChangeset().getPathsToDelete()){
List<File> deletedFiles = deleteHierarchy(commit.getScmContext(), path);
updatedFiles.addAll(deletedFiles);
}
if(updatedFiles.isEmpty()){
LOGGER.finest("Empty changeset to commit (no changes found on files) => commit skipped !");
checkedInCommits.add(commit);
} else {
// Commiting files...
boolean result = scmManipulator.checkinFiles(scmRoot, commit.getMessage());
if(result){
LOGGER.finest("Commit "+commit.toString()+" pushed to SCM !");
checkedInCommits.add(commit);
} else {
throw new LoggableException("Error while checking in file to scm repository", SCMManipulator.class, "checkinFiles");
}
signal(logMessage, true);
}
}