Search in sources :

Example 1 with GitLineHandler

use of git4idea.commands.GitLineHandler in project intellij-community by JetBrains.

the class GitStash method perform.

/**
   * {@inheritDoc}
   */
protected void perform(@NotNull final Project project, @NotNull final List<VirtualFile> gitRoots, @NotNull final VirtualFile defaultRoot) {
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    if (changeListManager.isFreezedWithNotification("Can not stash changes now"))
        return;
    GitStashDialog d = new GitStashDialog(project, gitRoots, defaultRoot);
    if (!d.showAndGet()) {
        return;
    }
    VirtualFile root = d.getGitRoot();
    final GitLineHandler h = d.handler();
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        GitHandlerUtil.doSynchronously(h, GitBundle.getString("stashing.title"), h.printableCommandLine());
    } finally {
        token.finish();
    }
    VfsUtil.markDirtyAndRefresh(false, true, false, root);
    if (!h.errors().isEmpty()) {
        showErrors(project, getActionName(), h.errors());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GitLineHandler(git4idea.commands.GitLineHandler) GitStashDialog(git4idea.ui.GitStashDialog) AccessToken(com.intellij.openapi.application.AccessToken) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 2 with GitLineHandler

use of git4idea.commands.GitLineHandler in project intellij-community by JetBrains.

the class GitResetHead method perform.

/**
   * {@inheritDoc}
   */
protected void perform(@NotNull Project project, @NotNull List<VirtualFile> gitRoots, @NotNull VirtualFile defaultRoot) {
    GitResetDialog d = new GitResetDialog(project, gitRoots, defaultRoot);
    if (!d.showAndGet()) {
        return;
    }
    GitLineHandler h = d.handler();
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        GitHandlerUtil.doSynchronously(h, GitBundle.getString("resetting.title"), h.printableCommandLine());
    } finally {
        token.finish();
    }
    GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
    manager.updateRepository(d.getGitRoot());
    VfsUtil.markDirtyAndRefresh(true, true, false, d.getGitRoot());
    if (!h.errors().isEmpty()) {
        showErrors(project, getActionName(), h.errors());
    }
}
Also used : GitLineHandler(git4idea.commands.GitLineHandler) GitResetDialog(git4idea.ui.GitResetDialog) AccessToken(com.intellij.openapi.application.AccessToken) GitRepositoryManager(git4idea.repo.GitRepositoryManager)

Example 3 with GitLineHandler

use of git4idea.commands.GitLineHandler in project intellij-community by JetBrains.

the class GitPullDialog method makeHandler.

public GitLineHandler makeHandler(@NotNull List<String> urls) {
    GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitCommand.PULL);
    h.setUrls(urls);
    h.addProgressParameter();
    h.addParameters("--no-stat");
    if (myNoCommitCheckBox.isSelected()) {
        h.addParameters("--no-commit");
    } else {
        if (myAddLogInformationCheckBox.isSelected()) {
            h.addParameters("--log");
        }
    }
    if (mySquashCommitCheckBox.isSelected()) {
        h.addParameters("--squash");
    }
    if (myNoFastForwardCheckBox.isSelected()) {
        h.addParameters("--no-ff");
    }
    String strategy = (String) myStrategy.getSelectedItem();
    if (!GitMergeUtil.DEFAULT_STRATEGY.equals(strategy)) {
        h.addParameters("--strategy", strategy);
    }
    h.addParameters("-v");
    h.addProgressParameter();
    final List<String> markedBranches = myBranchChooser.getMarkedElements();
    String remote = getRemote();
    LOG.assertTrue(remote != null, "Selected remote can't be null here.");
    // git pull origin master (remote branch name in the format local to that remote)
    h.addParameters(remote);
    for (String branch : markedBranches) {
        h.addParameters(removeRemotePrefix(branch, remote));
    }
    return h;
}
Also used : GitLineHandler(git4idea.commands.GitLineHandler)

Example 4 with GitLineHandler

use of git4idea.commands.GitLineHandler in project intellij-community by JetBrains.

the class GitStashDialog method handler.

public GitLineHandler handler() {
    GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
    handler.addParameters("save");
    if (myKeepIndexCheckBox.isSelected()) {
        handler.addParameters("--keep-index");
    }
    final String msg = myMessageTextField.getText().trim();
    if (msg.length() != 0) {
        handler.addParameters(msg);
    }
    return handler;
}
Also used : GitLineHandler(git4idea.commands.GitLineHandler)

Example 5 with GitLineHandler

use of git4idea.commands.GitLineHandler in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudAttachDialog method stash.

private boolean stash() {
    if (!syncResult.hasLocalRepository()) {
        LOG.error("unexpected null local repro in call to stash");
        return false;
    }
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    if (changeListManager.isFreezedWithNotification("Can not stash changes now")) {
        return false;
    }
    final GitLineHandler handler = new GitLineHandler(project, sourceRepository.getRoot(), GitCommand.STASH);
    handler.addParameters("save");
    handler.addParameters("--keep-index");
    String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date());
    stashMessage = "Cloud Debugger saved changes from branch " + originalBranchName + " at " + date;
    handler.addParameters(stashMessage);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        GitHandlerUtil.doSynchronously(handler, GitBundle.getString("stashing.title"), handler.printableCommandLine());
    } finally {
        token.finish();
    }
    return true;
}
Also used : GitLineHandler(git4idea.commands.GitLineHandler) AccessToken(com.intellij.openapi.application.AccessToken) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Date(java.util.Date)

Aggregations

GitLineHandler (git4idea.commands.GitLineHandler)12 AccessToken (com.intellij.openapi.application.AccessToken)4 VcsException (com.intellij.openapi.vcs.VcsException)4 Computable (com.intellij.openapi.util.Computable)2 Key (com.intellij.openapi.util.Key)2 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GitLineHandlerAdapter (git4idea.commands.GitLineHandlerAdapter)2 GitRepositoryManager (git4idea.repo.GitRepositoryManager)2 Nullable (org.jetbrains.annotations.Nullable)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 FilePath (com.intellij.openapi.vcs.FilePath)1 GitPlatformFacade (git4idea.GitPlatformFacade)1 GitVcs (git4idea.GitVcs)1 Git (git4idea.commands.Git)1 GitCommandResult (git4idea.commands.GitCommandResult)1 GitLocalChangesWouldBeOverwrittenDetector (git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector)1 GitSimpleHandler (git4idea.commands.GitSimpleHandler)1