mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-07 03:36:16 +00:00
refactor!: Migrate runners cmd from string to argv (#134)
Migrate command execution to structured argv lists across the plugin, replacing shell-string command construction with `vim.system` argv execution. The runner API now exposes argv-based execution as the default path:
- `runner.execute_command` -> `runner.execute`
- `runner.execute_command_async` -> `runner.execute_async`
- `runner.execute_command_raw` -> `runner.execute_raw`
- `runner.execute_command_raw_async` -> `runner.execute_raw_async`
- `runner.execute_command_sync` was removed; use `runner.execute` and handle the result directly
BREAKING CHANGES:
- `cmd.new({ args = ... })` now requires `args` as `string[]` argv tokens, not a single string.
- `cmd.log({ ... })` now uses `raw_flags` as `string[]` for raw passthrough flags; `raw = "..."` is no longer supported.
- Direct users of `jj.core.runner` must migrate from the old `execute_command*` string helpers to the new argv-based `execute*` helpers.
This commit is contained in:
+16
-7
@@ -10,11 +10,20 @@ local file = require("jj.file")
|
||||
--- @param path string The file path (absolute or repo-relative)
|
||||
--- @param enc? jj.file.enc Encoding settings for the file content
|
||||
local function open_revision(rev, path, enc)
|
||||
local raw_ids, ok = runner.execute_command(
|
||||
string.format([[jj log --no-graph -r %s -T 'change_id ++ "\n"' --quiet]], vim.fn.shellescape(rev)),
|
||||
"jj: failed to resolve revision"
|
||||
)
|
||||
if not ok or not raw_ids then return end
|
||||
local cmd = {
|
||||
"jj",
|
||||
"log",
|
||||
"--no-graph",
|
||||
"-r",
|
||||
rev,
|
||||
"-T",
|
||||
'change_id ++ "\n"',
|
||||
"--quiet",
|
||||
}
|
||||
local raw_ids, ok = runner.execute(cmd, "jj: failed to resolve revision")
|
||||
if not ok or not raw_ids then
|
||||
return
|
||||
end
|
||||
local ids = vim.split(vim.trim(raw_ids), "\n", { trimempty = true })
|
||||
if #ids ~= 1 then
|
||||
utils.notify(string.format("Revision '%s' is ambiguous", rev), vim.log.levels.ERROR)
|
||||
@@ -144,13 +153,13 @@ diff.register_backend("native", {
|
||||
show_revision = function(opts)
|
||||
local terminal = require("jj.ui.terminal")
|
||||
|
||||
local cmd = string.format("jj show -r %s --quiet --no-pager", opts.rev)
|
||||
local cmd = { "jj", "show", "-r", opts.rev, "--quiet", "--no-pager" }
|
||||
terminal.run_floating(cmd)
|
||||
end,
|
||||
diff_revisions = function(opts)
|
||||
local terminal = require("jj.ui.terminal")
|
||||
|
||||
local cmd = string.format("jj diff -f %s -t %s --quiet --no-pager", opts.left, opts.right)
|
||||
local cmd = { "jj", "diff", "-f", opts.left, "-t", opts.right, "--quiet", "--no-pager" }
|
||||
terminal.run_floating(cmd)
|
||||
end,
|
||||
diff_history_revisions = function(_)
|
||||
|
||||
Reference in New Issue
Block a user