Skip to content

Commit

Permalink
Other: move revert command to an individual file
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Aug 20, 2017
1 parent 6cc4f52 commit ddc0036
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
},
{
"caption": "git: revert",
"command": "gs_log_revert_commit"
"command": "gs_revert_commit"
},
{
"caption": "git: show current file at commit",
Expand Down
1 change: 1 addition & 0 deletions core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .custom import *
from .flow import *
from .cherry_pick import *
from .revert import *
from .tag import *
from .show_file_at_commit import *
from .git_add import *
Expand Down
16 changes: 0 additions & 16 deletions core/commands/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@ class GsLogCurrentBranchCommand(LogMixin, WindowCommand, GitCommand):
pass


class GsLogRevertCommitCommand(LogMixin, WindowCommand, GitCommand):
def do_action(self, commit_hash, **kwargs):
self.window.run_command("gs_revert_commit", {
"commit_hash": commit_hash
})


class GsRevertCommitCommand(WindowCommand, GitCommand):
def run(self, commit_hash):
sublime.set_timeout_async(lambda: self.run_async(commit_hash=commit_hash), 0)

def run_async(self, commit_hash):
self.git("revert", commit_hash)
util.view.refresh_gitsavvy(self.window.active_view(), refresh_sidebar=True)


class GsLogAllBranchesCommand(LogMixin, WindowCommand, GitCommand):

def log(self, **kwargs):
Expand Down
19 changes: 19 additions & 0 deletions core/commands/revert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from sublime_plugin import WindowCommand

from .log import LogMixin
from ..git_command import GitCommand
from ...common import util


class GsRevertCommitCommand(LogMixin, WindowCommand, GitCommand):

def run_async(self, **kwargs):
if "commit_hash" in kwargs:
commit_hash = kwargs["commit_hash"]
self.do_action(commit_hash)
else:
super().run_async(**kwargs)

def do_action(self, commit_hash, **kwargs):
self.git("revert", commit_hash)
util.view.refresh_gitsavvy(self.window.active_view(), refresh_sidebar=True)

0 comments on commit ddc0036

Please sign in to comment.