Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to customize graph output #360

Open
wants to merge 2 commits into
base: python3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Git.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions history.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sublime_plugin
import functools
import re
import shlex

import sublime
from .git import GitTextCommand, GitWindowCommand, plugin_file
Expand Down Expand Up @@ -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"))
Expand Down
5 changes: 3 additions & 2 deletions syntax/Git Graph.JSON-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -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?$",
Expand Down