mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +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:
+9
-13
@@ -1,6 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
local utils = require("jj.utils")
|
||||
local jj_args = require("jj.core.args")
|
||||
local terminal = require("jj.ui.terminal")
|
||||
local runner = require("jj.core.runner")
|
||||
|
||||
@@ -16,27 +17,22 @@ function M.resolve(opts)
|
||||
return
|
||||
end
|
||||
|
||||
local cmd_args = { "jj", "resolve", "--revision", rev }
|
||||
local cmd = { "jj", "resolve", "--revision", rev }
|
||||
-- Extra arguments
|
||||
vim.list_extend(cmd_args, args)
|
||||
-- Append the filestes
|
||||
for _, fileset in ipairs(filesets) do
|
||||
table.insert(cmd_args, utils.escape_fileset(fileset))
|
||||
end
|
||||
vim.list_extend(cmd, args)
|
||||
|
||||
local escaped_cmd_args = {}
|
||||
for _, arg in ipairs(cmd_args) do
|
||||
table.insert(escaped_cmd_args, vim.fn.shellescape(arg))
|
||||
-- Append filesets as jj string literal
|
||||
for _, fileset in ipairs(filesets) do
|
||||
table.insert(cmd, jj_args.fileset(fileset))
|
||||
end
|
||||
local shell_cmd = table.concat(escaped_cmd_args, " ")
|
||||
|
||||
utils.notify(string.format("Resolving conflicts in change `%s`...", rev), vim.log.levels.INFO)
|
||||
|
||||
-- If external is set, run the command asynchronously and invoke the on_exit callback if provided
|
||||
if opts.external then
|
||||
-- Run the command asynchronously and notify the user of the result
|
||||
runner.execute_command_async(
|
||||
shell_cmd,
|
||||
runner.execute_async(
|
||||
cmd,
|
||||
function(output)
|
||||
if output and output ~= "" then
|
||||
utils.notify(output, vim.log.levels.INFO)
|
||||
@@ -56,7 +52,7 @@ function M.resolve(opts)
|
||||
)
|
||||
else
|
||||
-- Otherwise, run in a floating terminal
|
||||
terminal.run_floating(cmd_args, nil, {
|
||||
terminal.run_floating(cmd, nil, {
|
||||
title = " JJ Resolve ",
|
||||
modifiable = true,
|
||||
keep_modifiable = true,
|
||||
|
||||
Reference in New Issue
Block a user