Adds git method

This commit is contained in:
Michel Fedde 2025-02-18 00:53:46 +01:00
parent b7da3ade1c
commit d34742c3bd
7 changed files with 87 additions and 10 deletions

View file

@ -6,7 +6,7 @@ function git.commitFile(filepath)
return vim.fn.fnamemodify(file, ":t:r")
end
local commitMessage = get_file_name(filepath) .. "-" .. os.date("%m_%B_%Y")
local commitMessage = get_file_name(filepath) .. "-" .. os.date("%d_%B_%Y")
os.execute('git add "' .. filepath .. '"')
local commitCommand = 'git commit -m "' .. commitMessage .. '" &> /dev/null'
@ -25,6 +25,26 @@ function git.commitFile(filepath)
end
end
function git.commitRest()
local commitMessage = "Files changed since last commit-" .. os.date("%d_%B_%Y")
os.execute("git add .")
local commitCommand = 'git commit -m "' .. commitMessage .. '" &> /dev/null'
local commitResult = os.execute(commitCommand)
print("Commiting... " .. commitMessage)
if commitResult == 256 then
print("Nothing to commit")
return
elseif commitResult == 0 then
print("Commit complete")
else
print("Unknown Error " .. commitResult)
print(commitCommand)
return
end
end
function git.push()
print("Pushing changes...")
-- Push twice, in case the credentials expired. Ugly hack, but it works