From 2d6df945d760bdf582e52c1572333d3e923da697 Mon Sep 17 00:00:00 2001 From: Brad Sherman Date: Tue, 15 Jul 2025 03:21:24 -0500 Subject: [PATCH] feat: jj rebase command (#3) --- lua/jj/cmd.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lua/jj/cmd.lua b/lua/jj/cmd.lua index 963b83e..d53af17 100644 --- a/lua/jj/cmd.lua +++ b/lua/jj/cmd.lua @@ -803,6 +803,32 @@ function M.diff(opts) run(cmd) end +--- Jujutsu rebase +function M.rebase() + if not utils.ensure_jj() then + return + end + + -- show log before rebasing + M.log({}) + vim.ui.input({ + prompt = "Rebase destination: ", + default = "trunk()", + }, function(input) + if input then + local cmd = string.format("jj rebase -d '%s'", input) + utils.notify(string.format("Beginning rebase on %s", input), vim.log.levels.INFO) + local _, success = utils.execute_command(cmd, "Error rebasing") + if success then + utils.notify("Rebase successful.", vim.log.levels.INFO) + M.log({}) + end + else + close_terminal_buffer() + end + end) +end + --- @param args string|string[] jj command arguments function M.j(args) if not utils.ensure_jj() then @@ -838,6 +864,9 @@ function M.j(args) elseif subcommand == "new" then M.new({ show_log = true, args = table.concat(remaining_args, " "), with_input = false }) return + elseif subcommand == "rebase" then + M.rebase() + return end -- Run the command in the terminal