Skip to content

Commit

Permalink
Merge pull request #1925 from timbrel/iter-revert
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Jun 6, 2024
2 parents 54b58b3 + 5cc1af1 commit 867f626
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
3 changes: 1 addition & 2 deletions core/commands/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ def cherry_pick(self):
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)

def revert_commit(self):
self.git("revert", self._commit_hash)
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)
self.window.run_command("gs_revert_commit", {"commit_hash": self._commit_hash})

def compare_against(self):
self.window.run_command("gs_compare_against", {
Expand Down
5 changes: 1 addition & 4 deletions core/commands/log_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3192,10 +3192,7 @@ def cherry_pick(self, *commit_hash):
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)

def revert_commit(self, *commit_hash):
try:
self.git("revert", *commit_hash)
finally:
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)
self.window.run_command("gs_revert_commit", {"commit_hash": commit_hash})

def compare_commits(self, base_commit, target_commit, file_path=None):
self.window.run_command("gs_compare_commit", {
Expand Down
32 changes: 17 additions & 15 deletions core/commands/revert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,36 @@


class gs_revert_commit(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)

@on_worker
def do_action(self, commit_hash, **kwargs):
self.git("revert", commit_hash)
util.view.refresh_gitsavvy(self.window.active_view(), refresh_sidebar=True)
try:
self.git("revert", *(commit_hash if isinstance(commit_hash, list) else [commit_hash]))
finally:
util.view.refresh_gitsavvy(self.window.active_view(), refresh_sidebar=True)


class gs_revert_abort(GsWindowCommand):
@on_worker
def run(self):
self.git("revert", "--abort")
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)
try:
self.git("revert", "--abort")
finally:
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)


class gs_revert_continue(GsWindowCommand):
@on_worker
def run(self):
self.git("revert", "--continue")
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)
try:
self.git("revert", "--continue")
finally:
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)


class gs_revert_skip(GsWindowCommand):
@on_worker
def run(self):
self.git("revert", "--skip")
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)
try:
self.git("revert", "--skip")
finally:
util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True)

0 comments on commit 867f626

Please sign in to comment.