Skip to content

Commit

Permalink
Merge pull request #1594 from NeogitOrg/development
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey authored Dec 8, 2024
2 parents a38945a + 24d1375 commit 683ee5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/neogit/popups/commit/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ local notification = require("neogit.lib.notification")
local config = require("neogit.config")
local a = require("plenary.async")

---@param popup PopupData
---@return boolean
local function allow_empty(popup)
return vim.tbl_contains(popup:get_arguments(), "--allow-empty")
end

local function confirm_modifications()
if
git.branch.upstream()
Expand Down Expand Up @@ -37,7 +43,7 @@ local function do_commit(popup, cmd)
end

local function commit_special(popup, method, opts)
if not git.status.anything_staged() then
if not git.status.anything_staged() and not allow_empty(popup) then
if git.status.anything_unstaged() then
if input.get_permission("Nothing is staged. Commit all uncommitted changed?") then
opts.all = true
Expand Down Expand Up @@ -97,7 +103,7 @@ local function commit_special(popup, method, opts)
end

function M.commit(popup)
if not git.status.anything_staged() then
if not git.status.anything_staged() and not allow_empty(popup) then
notification.warn("No changes to commit.")
return
end
Expand All @@ -106,7 +112,7 @@ function M.commit(popup)
end

function M.extend(popup)
if not git.status.anything_staged() then
if not git.status.anything_staged() and not allow_empty(popup) then
if git.status.anything_unstaged() then
if input.get_permission("Nothing is staged. Commit all uncommitted changes?") then
git.status.stage_modified()
Expand Down Expand Up @@ -175,7 +181,7 @@ function M.absorb(popup)
return
end

if not git.status.anything_staged() then
if not git.status.anything_staged() and not allow_empty(popup) then
if git.status.anything_unstaged() then
if input.get_permission("Nothing is staged. Absorb all unstaged changes?") then
git.status.stage_modified()
Expand Down
4 changes: 4 additions & 0 deletions lua/neogit/popups/remote/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function M.add(popup)
else
notification.info("Added remote " .. name)
end

if input.get_permission("Fetch refs from " .. name .. "?") then
git.fetch.fetch_interactive(name, "", { "--tags" })
end
end
end

Expand Down

0 comments on commit 683ee5d

Please sign in to comment.