use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitFileUtils method excludeIgnoredFiles.
@NotNull
private static List<String> excludeIgnoredFiles(@NotNull Project project, @NotNull VirtualFile root, @NotNull List<String> paths) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.LS_FILES);
handler.setSilent(true);
handler.addParameters("--ignored", "--others", "--exclude-standard");
handler.endOptions();
handler.addParameters(paths);
String output = handler.run();
List<String> nonIgnoredFiles = new ArrayList<>(paths.size());
Set<String> ignoredPaths = new HashSet<>(Arrays.asList(StringUtil.splitByLines(output)));
for (String pathToCheck : paths) {
if (!ignoredPaths.contains(pathToCheck)) {
nonIgnoredFiles.add(pathToCheck);
}
}
return nonIgnoredFiles;
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitFileUtils method doDelete.
private static void doDelete(@NotNull Project project, @NotNull VirtualFile root, @NotNull List<String> paths, String... additionalOptions) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RM);
handler.addParameters(additionalOptions);
handler.endOptions();
handler.addParameters(paths);
handler.run();
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitVFSListener method performForceMove.
private void performForceMove(@NotNull List<MovedFileInfo> files) {
Map<FilePath, MovedFileInfo> filesToMove = map2Map(files, (info) -> Pair.create(VcsUtil.getFilePath(info.myNewPath), info));
Set<File> toRefresh = newHashSet();
performBackgroundOperation(filesToMove.keySet(), "Moving Files...", new LongOperationPerRootExecutor() {
@Override
public void execute(@NotNull VirtualFile root, @NotNull List<FilePath> files) throws VcsException {
for (FilePath file : files) {
GitHandler h = new GitSimpleHandler(myProject, root, GitCommand.MV);
MovedFileInfo info = filesToMove.get(file);
h.addParameters("-f", info.myOldPath, info.myNewPath);
h.runInCurrentThread(null);
toRefresh.add(new File(info.myOldPath));
toRefresh.add(new File(info.myNewPath));
}
}
@Override
public Collection<File> getFilesToRefresh() {
return toRefresh;
}
});
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GithubUtil method addGithubRemote.
public static boolean addGithubRemote(@NotNull Project project, @NotNull GitRepository repository, @NotNull String remote, @NotNull String url) {
final GitSimpleHandler handler = new GitSimpleHandler(project, repository.getRoot(), GitCommand.REMOTE);
handler.setSilent(true);
try {
handler.addParameters("add", remote, url);
handler.run();
if (handler.getExitCode() != 0) {
GithubNotifications.showError(project, "Can't add remote", "Failed to add GitHub remote: '" + url + "'. " + handler.getStderr());
return false;
}
// catch newly added remote
repository.update();
return true;
} catch (VcsException e) {
GithubNotifications.showError(project, "Can't add remote", e);
return false;
}
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitUpdater method hasRemoteChanges.
protected boolean hasRemoteChanges(@NotNull String remoteBranch) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitCommand.REV_LIST);
handler.setSilent(true);
handler.addParameters("-1");
handler.addParameters(HEAD + ".." + remoteBranch);
String output = handler.run();
return output != null && !output.isEmpty();
}
Aggregations