a bunch of changes

This commit is contained in:
2026-04-17 15:49:58 +01:00
parent ca0708a8ee
commit a2d283a5c5
5 changed files with 16 additions and 27 deletions
+1
View File
@@ -1,5 +1,6 @@
return {
"HotThoughts/jjui.nvim",
enabled = false,
cmd = {
"JJUI",
"JJUICurrentFile",
+9 -25
View File
@@ -218,12 +218,12 @@ return {
},
-- git
{
"<leader>gcb",
"<leader>jc",
function()
local cwd = vim.fn.getcwd()
-- Helper to run git commands and capture both stdout and stderr
local function git_cmd(cmd)
-- Helper to run commands and capture both stdout and stderr
local function run_cmd(cmd)
local full_cmd = "cd " .. vim.fn.shellescape(cwd) .. " && " .. cmd .. " 2>&1"
local handle = io.popen(full_cmd)
local result = handle and handle:read("*a") or ""
@@ -234,7 +234,7 @@ return {
end
-- Check if in a git repo
local git_dir = git_cmd("git rev-parse --git-dir")
local git_dir = run_cmd("git rev-parse --git-dir")
if git_dir == "" or git_dir:match("^fatal") then
vim.notify("Not in a git repository", vim.log.levels.WARN)
return
@@ -242,7 +242,7 @@ return {
-- Get the default branch
local function branch_exists(branch)
local result = git_cmd("git rev-parse --verify refs/remotes/origin/" .. branch)
local result = run_cmd("git rev-parse --verify refs/remotes/origin/" .. branch)
-- If branch exists, rev-parse returns a hash; if not, it returns fatal error
return not result:match("^fatal")
end
@@ -259,19 +259,10 @@ return {
return
end
-- Get current branch
local current_branch = git_cmd("git branch --show-current")
if current_branch == "" then
current_branch = "HEAD"
end
local compare_target = "origin/" .. default_branch
-- Get files that differ from origin/main (includes committed + uncommitted changes)
local result = git_cmd("git diff --name-only " .. compare_target)
-- Also get untracked files
local untracked = git_cmd("git ls-files --others --exclude-standard")
local result = run_cmd("jj diff --from " .. default_branch .. "@origin --to @ --summary | awk '{print $2}'")
vim.notify(result)
-- Combine results
local all_files = {}
@@ -284,20 +275,13 @@ return {
end
end
for line in untracked:gmatch("[^\r\n]+") do
if line ~= "" and not seen[line] then
seen[line] = true
table.insert(all_files, { text = line .. " [untracked]", file = line })
end
end
if #all_files == 0 then
vim.notify("No modified files (vs " .. compare_target .. ")", vim.log.levels.INFO)
vim.notify("No modified files", vim.log.levels.INFO)
return
end
Snacks.picker({
title = "Modified Files (vs " .. compare_target .. ")",
title = "Modified Files",
items = all_files,
layout = { preset = "default" },
confirm = function(picker, item)