From 9f839b45b586e221b200cb16a76535e14500c1c6 Mon Sep 17 00:00:00 2001 From: Pete Kazmier Date: Sat, 16 Aug 2014 23:10:19 -0500 Subject: [PATCH 1/2] Added ability to customize graph output I enjoy this Git package, but I find the graph output to be a bit too lengthy for my taste. Added `git_graph_options` setting that can be customized by users. I prefer a more concise format: ``` "git_graph_options": "--pretty=format:'%h %ad | %s%d [%an]' --date=short" ``` Users will need to customize the syntax file based on their preferred graph options. --- Git.sublime-settings | 5 +++++ history.py | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Git.sublime-settings b/Git.sublime-settings index acd87e81..71ce4c04 100644 --- a/Git.sublime-settings +++ b/Git.sublime-settings @@ -9,6 +9,11 @@ // point this the installation location of git-flow ,"git_flow_command": "/usr/local/bin/git-flow" + // formatting options for the graph, these options are added to + // "git log --graph" command. "--follow" is added if generating a + // graph of a file. You'll probably want to change the syntax file. + ,"git_graph_options": "--pretty='%h -%d (%cr) (%ci) <%an> %s' --abbrev-commit --no-color --decorate --date=relative" + // use the panel for diff output, rather than a new scratch window (new tab) ,"diff_panel": false diff --git a/history.py b/history.py index 11205e83..7f65d926 100644 --- a/history.py +++ b/history.py @@ -1,6 +1,7 @@ import sublime_plugin import functools import re +import shlex import sublime from .git import GitTextCommand, GitWindowCommand, plugin_file @@ -133,11 +134,12 @@ class GitShowAllCommand(GitShow, GitWindowCommand): class GitGraph(object): def run(self, edit=None): + s = sublime.load_settings("Git.sublime-settings") + command = "git log --graph " + s.get("git_graph_options") filename = self.get_file_name() - self.run_command( - ['git', 'log', '--graph', '--pretty=%h -%d (%cr) (%ci) <%an> %s', '--abbrev-commit', '--no-color', '--decorate', '--date=relative', '--follow' if filename else None, '--', filename], - self.log_done - ) + if filename: + command = command + " --follow -- " + filename + self.run_command(shlex.split(command), self.log_done) def log_done(self, result): self.scratch(result, title="Git Log Graph", syntax=plugin_file("syntax/Git Graph.tmLanguage")) From 0be35b6da2452ca090dff8cb2d10a0ec61dc8954 Mon Sep 17 00:00:00 2001 From: Pete Kazmier Date: Sun, 17 Aug 2014 13:06:23 -0500 Subject: [PATCH 2/2] Synchronizing the JSON and XML syntax files Commit `c6636be` by @sheldon seems to have resulted in a disparity between the JSON Git Graph syntax file and the generated XML. This just updates the JSON to reflect the changes made to the XML. --- syntax/Git Graph.JSON-tmLanguage | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/syntax/Git Graph.JSON-tmLanguage b/syntax/Git Graph.JSON-tmLanguage index 926b3d6b..5897a352 100644 --- a/syntax/Git Graph.JSON-tmLanguage +++ b/syntax/Git Graph.JSON-tmLanguage @@ -2,14 +2,15 @@ "scopeName": "text.git-graph", "fileTypes": ["git-graph"], "patterns": [ - { "match": "^([| *\\\\]+)([0-9a-f]{4,40}) (.*?) (\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d [+-]\\d{4}) (?:\\(((?:[a-zA-Z0-9._\\-\\/]+(?:, )?)+)\\) )?", + { "match": "^([| *\\\\]+)([0-9a-f]{4,40}) -( \\(.*?\\))? (.*) (\\(.*) (<.*>) .*", "name": "log-entry.git-graph", "captures": { "1": {"name": "comment.git-graph" }, "2": {"name": "string.git-graph" }, "3": {"name": "support.function.git-graph" }, "4": {"name": "constant.numeric.git-graph" }, - "5": {"name": "variable.parameter.git-graph" } + "5": {"name": "variable.parameter.git-graph" }, + "6": {"name": "keyword.git-graph" } } }, { "match": "^\\|[\\|_\\/\\\\ ]+\n?$",