tools: Add git diff.

- This is worth it afterall.
- Eris will get out of sync when the diffs are commited,
  but this is also true of git-blame and git-log.
- The user can refresh the old results with shift-r.
This commit is contained in:
Andrew Hamilton 2021-07-11 16:25:25 +10:00
parent c5efd3a74b
commit 071096821c
4 changed files with 14 additions and 5 deletions

View file

@ -510,7 +510,7 @@ def make_tool_function(dependencies, command, url=None, success_status=None,
return func
elinks, git_blame = None, None # For linters.
elinks, git_diff, git_blame = None, None, None # For linters.
with importlib.resources.open_text(eris, "tools.toml") as tools_toml_file:
tools_toml = toml.load(tools_toml_file)
tools_for_extensions = tools_toml["tools_for_extensions"]
@ -685,6 +685,7 @@ def _tools_for_extension():
def tools_all():
tools_ = set(generic_tools())
tools_.add(git_diff)
tools_.add(git_blame)
tools_.add(git_log)
for tool_list in _tools_for_extension().values():
@ -727,7 +728,7 @@ def is_tool_available(tool):
def tools_for_path(path):
git_tools = [git_blame, git_log] if os.path.exists(".git") else []
git_tools = [git_diff, git_blame, git_log] if os.path.exists(".git") else []
root, ext = splitext(path)
extra_tools = [] if ext == "" else _tools_for_extension().get(ext[1:], [])
tools = generic_tools() + git_tools + extra_tools

View file

@ -111,6 +111,14 @@ tools_for_extensions = [
error_status = "not_applicable"
has_color = true
[git_diff]
dependencies = ["git"]
url = "https://git-scm.com/docs/git-diff"
command = "git diff --word-diff=color --exit-code"
success_status = "normal"
error_status = "problem"
has_color = true
[git_blame]
dependencies = ["git"]
url = "https://git-scm.com/docs/git-blame"