Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey committed Aug 6, 2023
1 parent 5a7d3ba commit 3024d90
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
6 changes: 6 additions & 0 deletions lua/neogit/lib/git/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ local configurations = {
},
},

["merge-base"] = config {
flags = {
is_ancestor = "--is-ancestor",
},
},

reset = config {
flags = {
hard = "--hard",
Expand Down
4 changes: 4 additions & 0 deletions lua/neogit/lib/git/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ function M.list(options, show_popup)
return parse_log(output.stdout, graph)
end

function M.is_ancestor(a, b)
return cli["merge-base"].is_ancestor.args(a, b):call_sync_ignoring_exit_code():trim().code == 0
end

local function update_recent(state)
local count = config.values.status.recent_commit_count
if count < 1 then
Expand Down
44 changes: 35 additions & 9 deletions lua/neogit/popups/commit/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,37 @@ local function commit_special(popup, method)
return
end

a.util.scheduler()
do_commit(popup, git.cli.commit.args(method, commit))
a.util.scheduler()

return commit
P(commit)

-- local block_rebase = false
-- if not git.log.is_ancestor(commit, "HEAD") then
-- local choice =
-- input.get_choice(string.format("'%s' isn't an ancestor of HEAD.", string.sub(commit, 1, 7)), {
-- values = {
-- "&create without rebasing",
-- "&select other",
-- "&abort",
-- },
-- default = 3,
-- })
--
-- if choice == "c" then
-- block_rebase = true
-- elseif choice == "s" then
-- commit_special(popup, method)
-- return
-- else
-- return
-- end
-- end
--
-- a.util.scheduler()
-- do_commit(popup, git.cli.commit.args(string.format("--%s=%s", method, commit)))
-- a.util.scheduler()
--
-- if not block_rebase then
-- return commit
-- end
end

function M.commit(popup)
Expand Down Expand Up @@ -83,15 +109,15 @@ function M.amend(popup)
end

function M.fixup(popup)
commit_special(popup, "--fixup")
commit_special(popup, "fixup")
end

function M.squash(popup)
commit_special(popup, "--squash")
commit_special(popup, "squash")
end

function M.instant_fixup(popup)
local commit = commit_special(popup, "--fixup")
local commit = commit_special(popup, "fixup")
if not commit then
return
end
Expand All @@ -100,7 +126,7 @@ function M.instant_fixup(popup)
end

function M.instant_squash(popup)
local commit = commit_special(popup, "--squash")
local commit = commit_special(popup, "squash")
if not commit then
return
end
Expand Down

0 comments on commit 3024d90

Please sign in to comment.