From f66db354105b9f6b6849943a875760948f3185d3 Mon Sep 17 00:00:00 2001 From: zhaoyanjun1 <> Date: Thu, 9 Aug 2018 00:11:02 +0800 Subject: [PATCH] Add a menu to checkout any version of the file --- Main.sublime-menu | 1 + git/history.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Main.sublime-menu b/Main.sublime-menu index cb8d1f96..d163417a 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -26,6 +26,7 @@ ,{ "caption": "-" } ,{ "caption": "Reset", "command": "git_raw", "args": { "command": "git reset HEAD", "append_current_file": true, "show_in": "suppress" } } ,{ "caption": "Checkout (Discard Changes)", "command": "git_raw", "args": { "command": "git checkout", "append_current_file": true } } + ,{ "caption": "Checkout (Any version)", "command": "git_log_checkout" } ,{ "caption": "-" } ,{ "caption": "Quick Commit Current File", "command": "git_quick_commit" } ,{ "caption": "Commit Selected Hunk", "command": "git_commit_selected_hunk" } diff --git a/git/history.py b/git/history.py index ccb959a9..4e006198 100644 --- a/git/history.py +++ b/git/history.py @@ -106,6 +106,16 @@ class GitLogAllCommand(GitLog, GitWindowCommand): pass +class GitLogCheckoutCommand(GitLogCommand): + """This command is used to check any version of a file.""" + def log_result(self, ref): + self.run_command( + ['git', 'checkout', ref, '--', self.get_file_name()]) + + def details_done(self, result): + pass + + class GitShow(object): def run(self, edit=None): # GitLog Copy-Past