From 39174d859854ea8e5e8b91d7dff25e767ce253d3 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 20 Oct 2023 23:41:49 +0200 Subject: [PATCH] Add "Compare with" and "Diff against" previous tip commands Ref #1768 --- core/commands/log_graph_rebase_actions.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/core/commands/log_graph_rebase_actions.py b/core/commands/log_graph_rebase_actions.py index df45a602d..44a6522c1 100644 --- a/core/commands/log_graph_rebase_actions.py +++ b/core/commands/log_graph_rebase_actions.py @@ -266,6 +266,18 @@ def run(self): ) ] + actions += [ + ( + "Compare with previous tip", + partial(self.compare_commits, current_branch, previous_tip) + ), + ( + "Diff against previous tip", + partial(self.diff_commit, previous_tip, current_branch) + ), + + ] + def on_action_selection(index): if index == -1: return @@ -370,6 +382,20 @@ def remove_previous_tip(self, view, previous_tip): settings.set("git_savvy.log_graph_view.filters", new_filters) view.run_command("gs_log_graph_refresh") + def compare_commits(self, base_commit, target_commit): + self.window.run_command("gs_compare_commit", { + "base_commit": base_commit, + "target_commit": target_commit, + }) + + def diff_commit(self, base_commit, target_commit): + self.window.run_command("gs_diff", { + "in_cached_mode": False, + "base_commit": base_commit, + "target_commit": target_commit, + "disable_stage": True + }) + def commit_message_from_line(view, line): # type: (sublime.View, TextRange) -> Optional[str]