mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 05:21:14 +01:00
Fix: Remove untracked files, clean directory after update.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
-- ~/.config/nvim/lua/update_kickestend.lua
|
|
||||||
-- Command: :UpdateKickestEnd
|
-- Command: :UpdateKickestEnd
|
||||||
-- Safely updates your KickestEnd.nvim config to the latest commit on origin/master
|
-- Safely updates KickestEnd.nvim config to the latest commit on origin/master
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('UpdateKickestEnd', function()
|
vim.api.nvim_create_user_command('UpdateKickestEnd', function()
|
||||||
local config_path = vim.fn.expand '~/.config/nvim'
|
local config_path = vim.fn.expand '~/.config/nvim'
|
||||||
@@ -11,19 +10,22 @@ vim.api.nvim_create_user_command('UpdateKickestEnd', function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check for local modifications
|
-- Check for local modifications or untracked files
|
||||||
local status = vim.fn.systemlist { 'git', '-C', config_path, 'status', '--porcelain' }
|
local status = vim.fn.systemlist { 'git', '-C', config_path, 'status', '--porcelain' }
|
||||||
local dirty = #status > 0
|
local dirty = #status > 0
|
||||||
|
|
||||||
if dirty then
|
if dirty then
|
||||||
local answer = vim.fn.input 'Local changes detected! Overwrite them and lose all changes? (y/N): '
|
local answer = vim.fn.input 'Local changes or new files detected! Overwrite and delete them? (y/N): '
|
||||||
if answer:lower() ~= 'y' then
|
if answer:lower() ~= 'y' then
|
||||||
vim.notify('Update cancelled to preserve your modifications.', vim.log.levels.WARN)
|
vim.notify('Update cancelled to preserve your modifications.', vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.notify('Discarding local modifications...', vim.log.levels.WARN)
|
vim.notify('Discarding all local changes and untracked files...', vim.log.levels.WARN)
|
||||||
|
|
||||||
|
-- Hard reset and clean untracked files/folders
|
||||||
vim.fn.system { 'git', '-C', config_path, 'reset', '--hard' }
|
vim.fn.system { 'git', '-C', config_path, 'reset', '--hard' }
|
||||||
|
vim.fn.system { 'git', '-C', config_path, 'clean', '-fdx' }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Fetch and update
|
-- Fetch and update
|
||||||
@@ -41,5 +43,5 @@ vim.api.nvim_create_user_command('UpdateKickestEnd', function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.notify('KickestEnd.nvim successfully updated to the latest commit on master!', vim.log.levels.INFO)
|
vim.notify('KickestEnd.nvim successfully updated and fully reset to origin/master!', vim.log.levels.INFO)
|
||||||
end, { desc = 'Safely update KickestEnd.nvim config from origin/master' })
|
end, { desc = 'Completely reset and update KickestEnd.nvim config from origin/master' })
|
||||||
|
|||||||
Reference in New Issue
Block a user