2424local function pushCmd (opts )
2525 local config = require (" tinygit.config" ).config .push
2626 local gitCommand = { " git" , " push" }
27+ local title = opts .forceWithLease and " Force push" or " Push"
2728 if opts .forceWithLease then table.insert (gitCommand , " --force-with-lease" ) end
2829
2930 vim .system (
3031 gitCommand ,
31- { detach = true , text = true },
32+ { detach = true },
3233 vim .schedule_wrap (function (result )
33- local out = vim .trim ((result .stdout or " " ) .. (result .stderr or " " )):gsub (" \n %s+" , " \n " ) -- fix leading spacing
34+ local out = vim .trim ((result .stdout or " " ) .. (result .stderr or " " ))
35+ out = out :gsub (" \n %s+" , " \n " ) -- remove padding
3436 local commitRange = out :match (" %x+%.%.%x+" )
3537
3638 -- notify
3739 if result .code == 0 then
3840 local numOfPushedCommits = u .syncShellCmd { " git" , " rev-list" , " --count" , commitRange }
3941 if numOfPushedCommits ~= " " then
4042 local plural = numOfPushedCommits ~= " 1" and " s" or " "
41- -- `[]` together with `ft=markdown` -> simple highlighting for `snacks.nvim`
42- out = out .. (" \n [%s commit%s]" ):format (numOfPushedCommits , plural )
43+ -- `[]` -> simple highlighting for `snacks.nvim`
44+ out = out .. (" \n [%d commit%s]" ):format (numOfPushedCommits , plural )
4345 end
4446 end
45- u .notify (out , result .code == 0 and " info" or " error" , { ft = ft , title = " Push " })
47+ u .notify (out , result .code == 0 and " info" or " error" , { title = title })
4648
4749 -- sound
4850 if config .confirmationSound and jit .os == " OSX" then
6769--- @param calledByCommitFunc ? boolean
6870function M .push (opts , calledByCommitFunc )
6971 local config = require (" tinygit.config" ).config .push
72+ if not opts then opts = {} end
73+ local title = opts .forceWithLease and " Force push" or " Push"
7074
7175 -- GUARD
7276 if u .notInGitRepo () then return end
@@ -75,12 +79,10 @@ function M.push(opts, calledByCommitFunc)
7579 u .syncShellCmd { " git" , " log" , " --oneline" , " --grep=^fixup!" , " --grep=^squash!" }
7680 if fixupOrSquashCommits ~= " " then
7781 local msg = " Aborting: There are fixup or squash commits.\n\n " .. fixupOrSquashCommits
78- u .notify (msg , " warn" , { title = " Push " })
82+ u .notify (msg , " warn" , { title = title })
7983 return
8084 end
8185 end
82- if not opts then opts = {} end
83- local title = opts .forceWithLease and " Force push" or " Push"
8486
8587 -- extra notification when called by user
8688 if not calledByCommitFunc then
@@ -115,7 +117,7 @@ function M.push(opts, calledByCommitFunc)
115117 -- Pull & Push
116118 vim .system (
117119 { " git" , " pull" },
118- { detach = true , text = true },
120+ { detach = true },
119121 vim .schedule_wrap (function (result )
120122 -- Git messaging is weird and sometimes puts normal messages into
121123 -- stderr, thus we need to merge stdout and stderr.
0 commit comments