mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git-index] add revert action to revert unstaged changes
GitOrigin-RevId: ee037cde6013a23bc95d318f3fb0cb70ad4f3dcb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
459e231dcc
commit
50d7b18b3c
@@ -18,6 +18,7 @@
|
||||
use-shortcut-of="Refresh"/>
|
||||
<action id="Git.Stage.Add" class="git4idea.index.actions.GitAddAction" use-shortcut-of="ChangesView.AddUnversioned"/>
|
||||
<action id="Git.Stage.Reset" class="git4idea.index.actions.GitResetAction" use-shortcut-of="ChangesView.Revert"/>
|
||||
<action id="Git.Stage.Revert" class="git4idea.index.actions.GitRevertAction" use-shortcut-of="ChangesView.Revert"/>
|
||||
|
||||
<group id="Git.Stage.Toolbar">
|
||||
<reference id="Diff.ShowDiff"/>
|
||||
@@ -26,6 +27,7 @@
|
||||
<group id="Git.Stage.Tree.Menu">
|
||||
<reference id="Git.Stage.Add"/>
|
||||
<reference id="Git.Stage.Reset"/>
|
||||
<reference id="Git.Stage.Revert"/>
|
||||
<reference id="Diff.ShowDiff"/>
|
||||
<separator/>
|
||||
<reference id="Vcs.ShowTabbedFileHistory"/>
|
||||
|
||||
@@ -570,6 +570,9 @@ stage.loading.status=Loading changes...
|
||||
stage.reset.action.text=Reset
|
||||
stage.reset.process=Resetting Files...
|
||||
stage.reset.error.title=Error Resetting Files
|
||||
stage.revert.action.text=Revert
|
||||
stage.revert.process=Reverting Back Files...
|
||||
stage.revert.error.title=Error Reverting Files
|
||||
|
||||
branches.selected.branches.updated.title=Selected {0,choice,1#branch|2#branches} Updated
|
||||
branches.update.failed=Update Failed
|
||||
|
||||
@@ -93,6 +93,20 @@ class GitResetAction : GitFileStatusNodeAction(GitBundle.messagePointer("stage.r
|
||||
}
|
||||
}
|
||||
|
||||
class GitRevertAction : GitFileStatusNodeAction(GitBundle.messagePointer("stage.revert.action.text")) {
|
||||
override fun matches(statusNode: GitFileStatusNode) = statusNode.kind == NodeKind.UNSTAGED
|
||||
|
||||
override fun processPaths(project: Project, root: VirtualFile, paths: List<FilePath>) {
|
||||
GitFileUtils.revertUnstagedPaths(project, root, paths)
|
||||
}
|
||||
|
||||
override fun progressTitle() = GitBundle.message("stage.revert.process")
|
||||
|
||||
override fun showErrorMessage(project: Project, exceptions: Collection<VcsException>) {
|
||||
showErrorMessage(project, GitBundle.message("stage.revert.error.title"), exceptions)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> runProcess(project: Project, title: @NlsContexts.ProgressTitle String, canBeCancelled: Boolean, process: () -> T): T {
|
||||
return ProgressManager.getInstance().runProcessWithProgressSynchronously<T, Exception>(ThrowableComputable { process() },
|
||||
title, canBeCancelled, project)
|
||||
|
||||
@@ -228,6 +228,15 @@ public class GitFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void revertUnstagedPaths(@NotNull Project project, @NotNull VirtualFile root, @NotNull List<? extends FilePath> files) throws VcsException {
|
||||
for (List<String> paths : VcsFileUtil.chunkPaths(root, files)) {
|
||||
GitLineHandler handler = new GitLineHandler(project, root, GitCommand.CHECKOUT);
|
||||
handler.endOptions();
|
||||
handler.addParameters(paths);
|
||||
Git.getInstance().runCommand(handler).throwOnError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file content for the specific revision
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user