Permalink
Browse files

Merge pull request #437 from rchl/issue_436

Improve showing full commits from the blame view. #436
  • Loading branch information...
2 parents b41f4cc + adf42c1 commit 517f7b49c31af0caab68f439f0e02be54e0f8be0 @kemayo committed Jan 6, 2016
Showing with 166 additions and 8 deletions.
  1. +1 −1 Default.sublime-keymap
  2. +20 −7 history.py
  3. +145 −0 syntax/Git Commit View.tmLanguage
@@ -3,6 +3,6 @@
"context": [{"key": "selector", "operand": "markup.inserted.diff"}]},
{"keys": ["enter"], "command": "git_goto_diff",
"context": [{"key": "selector", "operand": "markup.deleted.diff"}]},
- {"keys": ["enter"], "command": "git_goto_blame",
+ {"keys": ["enter"], "command": "git_goto_commit",
"context": [{"key": "selector", "operand": "text.git-blame"}]}
]
View
@@ -39,8 +39,10 @@ def get_lines(self):
return begin_line + 1, end_line + 1
def blame_done(self, result, position=None):
- self.scratch(result, title="Git Blame", position=position,
- syntax=plugin_file("syntax/Git Blame.tmLanguage"))
+ view = self.scratch(result, title="Git Blame", position=position,
+ syntax=plugin_file("syntax/Git Blame.tmLanguage"))
+ # store working dir to be potentially used by the GitGotoCommit command
+ view.settings().set("git_working_dir", self.get_working_dir())
class GitLog(object):
@@ -83,7 +85,8 @@ def log_result(self, ref):
self.details_done)
def details_done(self, result):
- self.scratch(result, title="Git Commit Details", syntax=plugin_file("syntax/Git Commit Message.tmLanguage"))
+ self.scratch(result, title="Git Commit Details",
+ syntax=plugin_file("syntax/Git Commit View.tmLanguage"))
class GitLogCommand(GitLog, GitTextCommand):
@@ -223,13 +226,23 @@ def show_done(self, result):
commits.sort(reverse=True)
commits = [commit for d, commit in commits]
- self.scratch('\n\n'.join(commits), title="Git Commit Documentation")
+ self.scratch('\n\n'.join(commits), title="Git Commit Documentation",
+ syntax=plugin_file("syntax/Git Commit View.tmLanguage"))
-class GitGotoBlame(sublime_plugin.TextCommand):
+class GitGotoCommit(GitTextCommand):
def run(self, edit):
- line = self.view.substr(self.view.line(self.view.sel()[0].a))
+ view = self.view
+ line = view.substr(view.line(view.sel()[0].a))
commit = line.split(" ")[0]
if not commit or commit == "00000000":
return
- self.view.window().run_command("git_raw", {"command": "git show %s" % commit, "show_in": "new_tab", "may_change_files": False})
+ working_dir = view.settings().get("git_working_dir")
+ self.run_command(['git', 'show', commit], self.show_done, working_dir=working_dir)
+
+ def show_done(self, result):
+ self.scratch(result, title="Git Commit View",
+ syntax=plugin_file("syntax/Git Commit View.tmLanguage"))
+
+ def is_enabled(self):
+ return True
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>fileTypes</key>
+ <array>
+ <string>git-commit-view</string>
+ </array>
+ <key>name</key>
+ <string>Git Commit View</string>
+ <key>patterns</key>
+ <array>
+ <dict>
+ <key>name</key>
+ <string>string.sha.git-blame</string>
+ <key>match</key>
+ <string>^commit [a-f0-9]+$</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>support.function.author.git-blame</string>
+ <key>match</key>
+ <string>^Author: .+$</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>constant.numeric.date.git-blame</string>
+ <key>match</key>
+ <string>^Date: .+$</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(^diff --.+$)</string>
+ <key>name</key>
+ <string>string.path.git-diff</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(^(((-{3}) .+)|((\*{3}) .+))$\n?|^(={4}) .+(?= - ))</string>
+ <key>name</key>
+ <string>meta.diff.header.from-file</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(^(\+{3}) .+$\n?| (-) .* (={4})$\n?)</string>
+ <key>name</key>
+ <string>meta.diff.header.to-file</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>1</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.range.diff</string>
+ </dict>
+ <key>2</key>
+ <dict>
+ <key>name</key>
+ <string>meta.toc-list.line-number.diff</string>
+ </dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.range.diff</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>^(@@)\s*(.+?)\s*(@@)($\n?)?</string>
+ <key>name</key>
+ <string>meta.diff.range.unified</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.inserted.diff</string>
+ </dict>
+ <key>6</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.inserted.diff</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>^(((&gt;)( .*)?)|((\+).*))$\n?</string>
+ <key>name</key>
+ <string>markup.inserted.diff</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>1</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.inserted.diff</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>^(!).*$\n?</string>
+ <key>name</key>
+ <string>markup.changed.diff</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.inserted.diff</string>
+ </dict>
+ <key>6</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.inserted.diff</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>^(((&lt;)( .*)?)|((-).*))$\n?</string>
+ <key>name</key>
+ <string>markup.deleted.diff</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>1</key>
+ <dict>
+ <key>name</key>
+ <string>meta.toc-list.file-name.diff</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>^index (.+)$\n?</string>
+ <key>name</key>
+ <string>meta.diff.index</string>
+ </dict>
+ </array>
+ <key>scopeName</key>
+ <string>text.git-commit-view</string>
+ <key>uuid</key>
+ <string>5d37add9-1219-4174-b232-4bd423b84c0a</string>
+</dict>
+</plist>

0 comments on commit 517f7b4

Please sign in to comment.