From 071096821ceae0748afdfeb82698856d82c9c09f Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Sun, 11 Jul 2021 16:25:25 +1000 Subject: [PATCH] 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. --- README.md | 4 ++-- eris/tools.py | 5 +++-- eris/tools.toml | 8 ++++++++ make-readme.py | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 10f80fb..0291f1b 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ There is a wrapper script available to make running easier: ## Tools -File types(100) | Tools(59) +File types(100) | Tools(60) ----------:| ----- -.* | [contents](http://pygments.org/) • [metadata](https://github.com/ahamilton/eris) • [git_blame](https://git-scm.com/docs/git-blame) • [git_log](https://git-scm.com/docs/git-log) +.* | [contents](http://pygments.org/) • [metadata](https://github.com/ahamilton/eris) • [git_diff](https://git-scm.com/docs/git-diff) • [git_blame](https://git-scm.com/docs/git-blame) • [git_log](https://git-scm.com/docs/git-log) .py | [python_syntax](https://en.wikipedia.org/wiki/Python_syntax_and_semantics) • [python_unittests](https://docs.python.org/3/library/unittest.html) • [pytest](https://docs.pytest.org/en/latest/) • [pydoc](https://docs.python.org/3/library/pydoc.html) • [mypy](http://mypy-lang.org/) • [python_coverage](https://coverage.readthedocs.io/) • [pycodestyle](http://pycodestyle.pycqa.org/en/latest/) • [pydocstyle](http://www.pydocstyle.org/en/2.1.1/usage.html) • [pyflakes](https://pypi.org/project/pyflakes/) • [pylint](https://www.pylint.org/) • [python_gut](https://github.com/ahamilton/eris) • [python_modulefinder](https://docs.python.org/3/library/modulefinder.html) • [dis](https://docs.python.org/3/library/dis.html) • [python_mccabe](https://pypi.org/project/mccabe/) • [bandit](https://pypi.org/project/bandit/) .pl .pm .t | [perl_syntax](https://en.wikipedia.org/wiki/Perl) • [perldoc](http://perldoc.perl.org/) .p6 .pm6 | [perl6_syntax](https://rakudo.org/) diff --git a/eris/tools.py b/eris/tools.py index c009fd5..3cf980f 100755 --- a/eris/tools.py +++ b/eris/tools.py @@ -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 diff --git a/eris/tools.toml b/eris/tools.toml index 2586004..9255fab 100644 --- a/eris/tools.toml +++ b/eris/tools.toml @@ -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" diff --git a/make-readme.py b/make-readme.py index 6a93e46..688a62c 100755 --- a/make-readme.py +++ b/make-readme.py @@ -7,7 +7,7 @@ import eris.tools as tools def main(): all_tools = ([(["*"], tools.generic_tools() + - [tools.git_blame, tools.git_log])] + + [tools.git_diff, tools.git_blame, tools.git_log])] + tools.TOOLS_FOR_EXTENSIONS) tool_set = set() extension_set = set()