Skip to content

Commit bceeb0e

Browse files
committed
feat(git_status): add push commands
1 parent 71ec083 commit bceeb0e

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ use {
6464
["ga"] = "git_add_file",
6565
["gr"] = "git_revert_file",
6666
["gc"] = "git_commit"
67+
["gp"] = "git_push",
68+
["gg"] = "git_commit_and_push",
6769
}
6870
}
6971
}

doc/neo-tree.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,5 +367,7 @@ specific commands:
367367
["gu"] = "git_unstage_file",
368368
["gr"] = "git_revert_file",
369369
["gc"] = "git_commit"
370+
["gp"] = "git_push",
371+
["gg"] = "git_commit_and_push",
370372

371373
vim:tw=80:ts=2:et:ft=help:

lua/neo-tree/sources/git_status/commands.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ M.git_add_all = function (state)
2323
gs.refresh()
2424
end
2525

26-
M.git_commit = function (state)
26+
M.git_commit = function (state, and_push)
2727
local width = vim.fn.winwidth(0) - 2
2828
local row = vim.api.nvim_win_get_height(0) - 3
2929
local popup_options = {
@@ -38,12 +38,29 @@ M.git_commit = function (state)
3838
inputs.input("Commit message: ", "", function (msg)
3939
msg = msg:gsub('"', "'")
4040
local cmd = "git commit -m \"" .. msg .. "\""
41+
if and_push then
42+
cmd = cmd .. " && git push"
43+
end
4144
local result = vim.fn.systemlist(cmd)
4245
gs.refresh()
4346
popups.alert("Commit Results", result)
4447
end, popup_options)
4548
end
4649

50+
M.git_commit_and_push = function (state)
51+
M.git_commit(state, true)
52+
end
53+
54+
M.git_push = function (state)
55+
inputs.confirm("Are you sure you want to push your changes?", function (yes)
56+
if yes then
57+
local result = vim.fn.systemlist("git push")
58+
gs.refresh()
59+
popups.alert("Git Push", result)
60+
end
61+
end)
62+
end
63+
4764
M.git_unstage_file = function (state)
4865
local node = state.tree:get_node()
4966
local path = node:get_id()

lua/neo-tree/sources/git_status/defaults.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ local filesystem = {
2424
["gu"] = "git_unstage_file",
2525
["ga"] = "git_add_file",
2626
["gr"] = "git_revert_file",
27-
["gc"] = "git_commit"
27+
["gc"] = "git_commit",
28+
["gp"] = "git_push",
29+
["gg"] = "git_commit_and_push",
2830
}
2931
},
3032
before_render = function(state)

0 commit comments

Comments
 (0)