commit.setEnabled(enabled && containsCommitable(table));
}
private static void performCommit(String message, Map<GitFileNode, CommitOptions> commitFiles,
VCSContext ctx, GitProgressSupport support, String prjName, OutputLogger logger) {
StatusCache cache = Git.getInstance().getStatusCache();
final File repository = GitUtils.getRootFile(ctx);
List<File> addCandidates = new ArrayList<File>();
List<File> deleteCandidates = new ArrayList<File>();
int commitCandidates = 0;
List<String> excPaths = new ArrayList<String>();
List<String> incPaths = new ArrayList<String>();
for (GitFileNode node : commitFiles.keySet()) {
if (support.isCanceled()) {
return;
}
CommitOptions option = commitFiles.get(node);
if (option != CommitOptions.EXCLUDE) {
int status = cache.getStatus(node.getFile()).getStatus();
if ((status & StatusInfo.STATUS_NOTVERSIONED_NEWLOCALLY) != 0) {
addCandidates.add(node.getFile());
} else if ((status & StatusInfo.STATUS_VERSIONED_DELETEDLOCALLY) != 0) {
deleteCandidates.add(node.getFile());
} else {
addCandidates.add(node.getFile());
}
commitCandidates++;
incPaths.add(node.getFile().getAbsolutePath());
} else {
excPaths.add(node.getFile().getAbsolutePath());
}
}
if (support.isCanceled()) {
return;
}
if (!excPaths.isEmpty()) {
GitModuleConfig.getDefault().addExclusionPaths(excPaths);
}
if (!incPaths.isEmpty()) {
GitModuleConfig.getDefault().removeExclusionPaths(incPaths);
}
try {
logger.outputInRed(
NbBundle.getMessage(CommitAction.class,
"MSG_COMMIT_TITLE")); // NOI18N
logger.outputInRed(
NbBundle.getMessage(CommitAction.class,
"MSG_COMMIT_TITLE_SEP")); // NOI18N
logger.output(message); // NOI18N
CommitBuilder.create(repository).
log(logger).
addAll(addCandidates).
deleteAll(deleteCandidates).
message(message).
write();
if (commitCandidates == 1) {
logger.output(
NbBundle.getMessage(CommitAction.class,
"MSG_COMMIT_INIT_SEP_ONE", commitCandidates, prjName));
} else {
logger.output(
NbBundle.getMessage(CommitAction.class,
"MSG_COMMIT_INIT_SEP", commitCandidates, prjName));
}
} catch (Exception ex) {
notifyLater(ex);
} finally {
cache.refreshCached(ctx);
logger.outputInRed(NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_DONE")); // NOI18N
logger.output(""); // NOI18N
}
}