claude-baseline-1752117543
This commit is contained in:
parent
15308b5cb7
commit
1b73512226
|
@ -25,3 +25,7 @@ Now baseline exists - this should work properly!
|
||||||
Testing with debug logs to see what's happening in the hooks.
|
Testing with debug logs to see what's happening in the hooks.
|
||||||
|
|
||||||
After reloading hooks module - this should create debug logs!
|
After reloading hooks module - this should create debug logs!
|
||||||
|
|
||||||
|
Testing after manual baseline creation - this should work now!
|
||||||
|
|
||||||
|
After manually initializing stash session - test the browsing commands!
|
||||||
|
|
|
@ -130,7 +130,7 @@ end
|
||||||
-- Get Claude stashes (only stashes with [claude-edit] messages)
|
-- Get Claude stashes (only stashes with [claude-edit] messages)
|
||||||
function M.get_claude_stashes()
|
function M.get_claude_stashes()
|
||||||
local utils = require('nvim-claude.utils')
|
local utils = require('nvim-claude.utils')
|
||||||
local cmd = 'git stash list --grep="claude-edit"'
|
local cmd = 'git stash list'
|
||||||
local result = utils.exec(cmd)
|
local result = utils.exec(cmd)
|
||||||
|
|
||||||
if not result or result == '' then
|
if not result or result == '' then
|
||||||
|
@ -139,7 +139,7 @@ function M.get_claude_stashes()
|
||||||
|
|
||||||
local stashes = {}
|
local stashes = {}
|
||||||
for line in result:gmatch('[^\n]+') do
|
for line in result:gmatch('[^\n]+') do
|
||||||
if line ~= '' then
|
if line ~= '' and line:match('%[claude%-edit%]') then
|
||||||
local stash_ref = line:match('^(stash@{%d+})')
|
local stash_ref = line:match('^(stash@{%d+})')
|
||||||
if stash_ref then
|
if stash_ref then
|
||||||
table.insert(stashes, {
|
table.insert(stashes, {
|
||||||
|
@ -174,10 +174,17 @@ function M.open_diffview()
|
||||||
-- Try to recover stash-based session from baseline
|
-- Try to recover stash-based session from baseline
|
||||||
local utils = require('nvim-claude.utils')
|
local utils = require('nvim-claude.utils')
|
||||||
local baseline_ref = utils.read_file('/tmp/claude-baseline-commit')
|
local baseline_ref = utils.read_file('/tmp/claude-baseline-commit')
|
||||||
if baseline_ref and baseline_ref ~= '' then
|
|
||||||
baseline_ref = baseline_ref:gsub('%s+', '')
|
-- If no baseline file, but we have Claude stashes, use HEAD as baseline
|
||||||
local claude_stashes = M.get_claude_stashes()
|
local claude_stashes = M.get_claude_stashes()
|
||||||
if claude_stashes and #claude_stashes > 0 then
|
if claude_stashes and #claude_stashes > 0 then
|
||||||
|
if not baseline_ref or baseline_ref == '' then
|
||||||
|
baseline_ref = 'HEAD'
|
||||||
|
vim.notify('No baseline found, using HEAD as baseline', vim.log.levels.INFO)
|
||||||
|
else
|
||||||
|
baseline_ref = baseline_ref:gsub('%s+', '')
|
||||||
|
end
|
||||||
|
|
||||||
M.current_review = {
|
M.current_review = {
|
||||||
baseline_ref = baseline_ref,
|
baseline_ref = baseline_ref,
|
||||||
timestamp = os.time(),
|
timestamp = os.time(),
|
||||||
|
@ -185,8 +192,7 @@ function M.open_diffview()
|
||||||
current_stash_index = 0, -- Show cumulative view by default
|
current_stash_index = 0, -- Show cumulative view by default
|
||||||
is_stash_based = true
|
is_stash_based = true
|
||||||
}
|
}
|
||||||
vim.notify('Recovered Claude stash session from baseline', vim.log.levels.INFO)
|
vim.notify(string.format('Recovered Claude stash session with %d stashes', #claude_stashes), vim.log.levels.INFO)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not M.current_review then
|
if not M.current_review then
|
||||||
|
|
|
@ -68,9 +68,18 @@ function M.pre_tool_use_hook()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Store the baseline commit reference
|
-- Store the actual commit hash instead of 'HEAD'
|
||||||
|
local hash_cmd = string.format('cd "%s" && git rev-parse HEAD', git_root)
|
||||||
|
local commit_hash, hash_err = utils.exec(hash_cmd)
|
||||||
|
|
||||||
|
if not hash_err and commit_hash and commit_hash ~= '' then
|
||||||
|
commit_hash = commit_hash:gsub('%s+', '')
|
||||||
|
M.baseline_commit = commit_hash
|
||||||
|
utils.write_file(baseline_file, commit_hash)
|
||||||
|
else
|
||||||
M.baseline_commit = 'HEAD'
|
M.baseline_commit = 'HEAD'
|
||||||
utils.write_file(baseline_file, 'HEAD')
|
utils.write_file(baseline_file, 'HEAD')
|
||||||
|
end
|
||||||
|
|
||||||
vim.notify('New baseline commit created: ' .. commit_msg, vim.log.levels.INFO)
|
vim.notify('New baseline commit created: ' .. commit_msg, vim.log.levels.INFO)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue