Add a patch command
- Make it easy to apply the patches some tools produce.
This commit is contained in:
parent
99ed8efc43
commit
754143b395
4 changed files with 18 additions and 7 deletions
|
|
@ -1,3 +1 @@
|
|||
|
||||
|
||||
__version__ = "v2025.06.14"
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ KEYS_DOC = """Keys:
|
|||
R - Refresh all reports of the current tool.
|
||||
f - Resize the focused pane to the full screen. (toggle)
|
||||
o - Open the current file with xdg-open.
|
||||
p - Patch the current file. (When viewing a patch from a tool)
|
||||
"""
|
||||
|
||||
|
||||
|
|
@ -786,6 +787,15 @@ class Screen:
|
|||
in_green(f" at line {line_num}…")])
|
||||
subprocess.Popen(f"{self.editor_command} +{line_num} {path}", shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
def patch_file(self):
|
||||
result = self._summary.get_selection()
|
||||
if hasattr(result.tool, "patch_command") and result.tool.patch_command is not None:
|
||||
path = result.path
|
||||
path_colored = lscolors.path_colored(path)
|
||||
self._log.log_message([in_green("Patching file: "), path_colored])
|
||||
subprocess.run(f"{result.tool.patch_command} {path} | patch -p0", shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
subprocess.run(["touch", path])
|
||||
|
||||
def toggle_status_style(self):
|
||||
self._summary.toggle_status_style(self._log)
|
||||
|
|
@ -915,7 +925,7 @@ class Screen:
|
|||
tools.STATUS_TO_TERMSTR[widget.status] + divider + "line " + str(y+1))
|
||||
|
||||
_STATUS_BAR = highlight_chars(" *help *quit *t*a*b:focus *turn *log *edit *next *sort"
|
||||
" *refresh *fullscreen *open", Log._GREEN_STYLE)
|
||||
" *refresh *fullscreen *open *patch", Log._GREEN_STYLE)
|
||||
|
||||
@functools.cache
|
||||
def _get_partial_bar_chars(self, bar_transparency):
|
||||
|
|
@ -963,9 +973,9 @@ class Screen:
|
|||
terminal.RIGHT: cursor_right, terminal.PAGE_DOWN: cursor_page_down,
|
||||
terminal.PAGE_UP: cursor_page_up, "s": toggle_order, terminal.HOME: cursor_home,
|
||||
terminal.END: cursor_end, "n": move_to_next_issue, "N": move_to_next_issue_of_tool,
|
||||
"e": edit_file, "q": quit_, terminal.ESC: quit_, terminal.CTRL_C: quit_,
|
||||
"r": refresh, "R": refresh_tool, "\t": toggle_focus, "f": toggle_fullscreen,
|
||||
"o": xdg_open}
|
||||
"e": edit_file, "p": patch_file, "q": quit_, terminal.ESC: quit_,
|
||||
terminal.CTRL_C: quit_, "r": refresh, "R": refresh_tool, "\t": toggle_focus,
|
||||
"f": toggle_fullscreen, "o": xdg_open}
|
||||
|
||||
|
||||
def setup_inotify(root_path, loop, on_filesystem_event, exclude_filter):
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ def git_log(path):
|
|||
|
||||
|
||||
def make_tool_function(dependencies, command, url=None, error_status=None,
|
||||
has_color=False, timeout=None):
|
||||
has_color=False, timeout=None, patch_command=None):
|
||||
if url is None:
|
||||
url = dependencies[0]
|
||||
command_parts = command.split()
|
||||
|
|
@ -448,6 +448,7 @@ def make_tool_function(dependencies, command, url=None, error_status=None,
|
|||
def func(path):
|
||||
return _run_command(command_parts + [path], error_status, has_color, timeout)
|
||||
func.command = command
|
||||
func.patch_command = patch_command
|
||||
return func
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -96,12 +96,14 @@ tools_for_extensions = [
|
|||
dependencies = ["black"]
|
||||
url = "https://github.com/psf/black"
|
||||
command = "black --check --diff --color"
|
||||
patch_command = "black --diff"
|
||||
has_color = true
|
||||
|
||||
[isort]
|
||||
dependencies = ["python3-isort", "python3-colorama"]
|
||||
url = "https://pycqa.github.io/isort/"
|
||||
command = "/usr/bin/python3 -m isort --check-only --diff --color"
|
||||
patch_command = "/usr/bin/python3 -m isort --diff"
|
||||
has_color = true
|
||||
|
||||
[perl_syntax]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue