mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-11 17:15:46 +08:00
feat(git): add :Git reset
command
This commit is contained in:
parent
c90dc3f00c
commit
d3478808e8
48
bundle/git.vim/lua/git/command/reset.lua
vendored
48
bundle/git.vim/lua/git/command/reset.lua
vendored
@ -1,7 +1,41 @@
|
|||||||
--=============================================================================
|
--=============================================================================
|
||||||
-- reset.lua --- Git reset command
|
-- reset.lua --- Git reset command
|
||||||
-- Copyright (c) 2016-2023 Wang Shidong & Contributors
|
-- Copyright (c) 2016-2023 Wang Shidong & Contributors
|
||||||
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
||||||
-- URL: https://spacevim.org
|
-- URL: https://spacevim.org
|
||||||
-- License: GPLv3
|
-- License: GPLv3
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
|
local m = {}
|
||||||
|
|
||||||
|
local job = require('spacevim.api.job')
|
||||||
|
local nt = require('spacevim.api.notify')
|
||||||
|
local log = require('git.log')
|
||||||
|
|
||||||
|
local function on_exit(id, code, single)
|
||||||
|
log.debug('git-reset exit code:' .. code .. ' single:' .. single)
|
||||||
|
if code == 0 and single == 0 then
|
||||||
|
if vim.fn.exists(':GitGutter') == 2 then
|
||||||
|
vim.cmd('GitGutter')
|
||||||
|
end
|
||||||
|
nt.notify('git reset done!')
|
||||||
|
else
|
||||||
|
nt.notify('git reset failed!')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function m.run(argv)
|
||||||
|
local cmd = { 'git', 'reset' }
|
||||||
|
if #argv == 1 and argv[1] == '%' then
|
||||||
|
cmd = { 'git', 'reset', 'HEAD', vim.fn.expand('%') }
|
||||||
|
else
|
||||||
|
for _, v in ipairs(argv) do
|
||||||
|
table.insert(cmd, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
log.debug('git-reset cmd:' .. vim.inspect(cmd))
|
||||||
|
job.start(cmd, {
|
||||||
|
on_exit = on_exit,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
||||||
|
Loading…
x
Reference in New Issue
Block a user