mirror of
https://github.com/CompeyDev/dotfiles.git
synced 2024-12-12 04:40:37 +00:00
fix: fix some bugs in git wrapper scripts
This commit is contained in:
parent
a544843b62
commit
aa7fbafb2c
3 changed files with 29 additions and 27 deletions
46
bin/gc.luau
46
bin/gc.luau
|
@ -10,11 +10,11 @@ function main(args: {string})
|
|||
return gitStatusChild.code
|
||||
end
|
||||
|
||||
local statusDiff:{{ file: string, type: string }} = {}
|
||||
local statusDiff: {{ file: string, type: string }} = {}
|
||||
local statusLines = gitStatusChild.stdout:split("\n")
|
||||
|
||||
for lineCount, line in statusLines do
|
||||
if lineCount >= 6 and lineCount then
|
||||
if lineCount > 6 then
|
||||
local type, file = line:match("^%s(.+): (.+)$")
|
||||
if type == nil then
|
||||
break
|
||||
|
@ -53,7 +53,7 @@ function main(args: {string})
|
|||
for type, filesAndCount: {
|
||||
count: number,
|
||||
[number]: string,
|
||||
} in typeCounts do
|
||||
} in typeCounts do
|
||||
local count = filesAndCount.count
|
||||
local bullet = dim("•")
|
||||
stdio.write(` {bullet} {
|
||||
|
@ -61,7 +61,7 @@ function main(args: {string})
|
|||
} files {type}`)
|
||||
|
||||
if count == 1 then
|
||||
stdio.write(` ({dim(filesAndCount[1])})`)
|
||||
stdio.write(` ({dim(filesAndCount[1]:gsub("%s", ""))})\n`)
|
||||
continue
|
||||
end
|
||||
|
||||
|
@ -70,29 +70,29 @@ function main(args: {string})
|
|||
files.count = nil
|
||||
for _, file in files do
|
||||
-- TODO: Map colors to type
|
||||
print(` {bullet} {stdio.color("cyan") .. file .. stdio.color("reset")}`)
|
||||
print(` {bullet} {stdio.color("cyan") .. file:gsub("%s", "") .. stdio.color("reset")}`)
|
||||
end
|
||||
end
|
||||
|
||||
print("Commit message:")
|
||||
-- TODO: Conventional commit prompts
|
||||
local commitMessage = stdio.prompt("text")
|
||||
local gitCommitChild = process.spawn("git", {"commit", "-a", "-m", commitMessage})
|
||||
if not gitCommitChild.ok then
|
||||
stdio.ewrite(gitCommitChild.stderr)
|
||||
return gitCommitChild.code
|
||||
end
|
||||
print("Commit message:")
|
||||
-- TODO: Conventional commit prompts
|
||||
local commitMessage = stdio.prompt("text")
|
||||
local gitCommitChild = process.spawn("git", {"commit", "-a", "-m", commitMessage})
|
||||
if not gitCommitChild.ok then
|
||||
stdio.ewrite(gitCommitChild.stderr)
|
||||
return gitCommitChild.code
|
||||
end
|
||||
|
||||
stdio.write("\n")
|
||||
local toPush = stdio.prompt("confirm", "Push changes to remote?")
|
||||
if toPush then
|
||||
local pushChild = process.spawn("lune", { "run", "$HOME/bin/gp.luau" }, {
|
||||
shell = true,
|
||||
stdio = "forward"
|
||||
})
|
||||
stdio.write("\n")
|
||||
local toPush = stdio.prompt("confirm", "Push changes to remote?")
|
||||
if toPush then
|
||||
local pushChild = process.spawn("lune", { "run", "$HOME/bin/gp.luau" }, {
|
||||
shell = true,
|
||||
stdio = "forward"
|
||||
})
|
||||
|
||||
if not pushChild.ok then
|
||||
return pushChild.code
|
||||
end
|
||||
if not pushChild.ok then
|
||||
return pushChild.code
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ local function outputToCommit(_, line)
|
|||
}
|
||||
end
|
||||
|
||||
function main(args: {string})
|
||||
function main(args: {string?})
|
||||
local range = args[1]
|
||||
local gitLogChild = process.spawn(
|
||||
"git",
|
||||
|
|
|
@ -2,7 +2,7 @@ local process = require("@lune/process")
|
|||
local stdio = require("@lune/stdio")
|
||||
local task = require("@lune/task")
|
||||
|
||||
local gitLog = require("./gl.luau")
|
||||
local gitLog = require("gl.luau")
|
||||
type Commit = gitLog.Commit
|
||||
|
||||
local function dots(count: number)
|
||||
|
@ -15,14 +15,16 @@ end
|
|||
function main(args: {string})
|
||||
print("Unpushed commits:")
|
||||
|
||||
local childExit = gitLog.main({"main..HEAD"})
|
||||
local childExit = gitLog.main({"origin/main..HEAD"})
|
||||
if childExit ~= 0 then
|
||||
return childExit
|
||||
end
|
||||
|
||||
stdio.write("Pushing to remote")
|
||||
task.spawn(dots, 3)
|
||||
local pushChild = process.spawn("git", {"push"})
|
||||
local pushChild = process.spawn("git", {"pull", "--rebase", "&&", "git", "push"}, {
|
||||
shell = true
|
||||
})
|
||||
if not pushChild.ok then
|
||||
stdio.ewrite("\r" .. pushChild.stderr)
|
||||
return pushChild.code
|
||||
|
|
Loading…
Reference in a new issue