mirror of
https://github.com/CompeyDev/dotfiles.git
synced 2025-01-06 02:49:09 +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
|
return gitStatusChild.code
|
||||||
end
|
end
|
||||||
|
|
||||||
local statusDiff:{{ file: string, type: string }} = {}
|
local statusDiff: {{ file: string, type: string }} = {}
|
||||||
local statusLines = gitStatusChild.stdout:split("\n")
|
local statusLines = gitStatusChild.stdout:split("\n")
|
||||||
|
|
||||||
for lineCount, line in statusLines do
|
for lineCount, line in statusLines do
|
||||||
if lineCount >= 6 and lineCount then
|
if lineCount > 6 then
|
||||||
local type, file = line:match("^%s(.+): (.+)$")
|
local type, file = line:match("^%s(.+): (.+)$")
|
||||||
if type == nil then
|
if type == nil then
|
||||||
break
|
break
|
||||||
|
@ -53,7 +53,7 @@ function main(args: {string})
|
||||||
for type, filesAndCount: {
|
for type, filesAndCount: {
|
||||||
count: number,
|
count: number,
|
||||||
[number]: string,
|
[number]: string,
|
||||||
} in typeCounts do
|
} in typeCounts do
|
||||||
local count = filesAndCount.count
|
local count = filesAndCount.count
|
||||||
local bullet = dim("•")
|
local bullet = dim("•")
|
||||||
stdio.write(` {bullet} {
|
stdio.write(` {bullet} {
|
||||||
|
@ -61,7 +61,7 @@ function main(args: {string})
|
||||||
} files {type}`)
|
} files {type}`)
|
||||||
|
|
||||||
if count == 1 then
|
if count == 1 then
|
||||||
stdio.write(` ({dim(filesAndCount[1])})`)
|
stdio.write(` ({dim(filesAndCount[1]:gsub("%s", ""))})\n`)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,29 +70,29 @@ function main(args: {string})
|
||||||
files.count = nil
|
files.count = nil
|
||||||
for _, file in files do
|
for _, file in files do
|
||||||
-- TODO: Map colors to type
|
-- 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
|
||||||
|
end
|
||||||
|
|
||||||
print("Commit message:")
|
print("Commit message:")
|
||||||
-- TODO: Conventional commit prompts
|
-- TODO: Conventional commit prompts
|
||||||
local commitMessage = stdio.prompt("text")
|
local commitMessage = stdio.prompt("text")
|
||||||
local gitCommitChild = process.spawn("git", {"commit", "-a", "-m", commitMessage})
|
local gitCommitChild = process.spawn("git", {"commit", "-a", "-m", commitMessage})
|
||||||
if not gitCommitChild.ok then
|
if not gitCommitChild.ok then
|
||||||
stdio.ewrite(gitCommitChild.stderr)
|
stdio.ewrite(gitCommitChild.stderr)
|
||||||
return gitCommitChild.code
|
return gitCommitChild.code
|
||||||
end
|
end
|
||||||
|
|
||||||
stdio.write("\n")
|
stdio.write("\n")
|
||||||
local toPush = stdio.prompt("confirm", "Push changes to remote?")
|
local toPush = stdio.prompt("confirm", "Push changes to remote?")
|
||||||
if toPush then
|
if toPush then
|
||||||
local pushChild = process.spawn("lune", { "run", "$HOME/bin/gp.luau" }, {
|
local pushChild = process.spawn("lune", { "run", "$HOME/bin/gp.luau" }, {
|
||||||
shell = true,
|
shell = true,
|
||||||
stdio = "forward"
|
stdio = "forward"
|
||||||
})
|
})
|
||||||
|
|
||||||
if not pushChild.ok then
|
if not pushChild.ok then
|
||||||
return pushChild.code
|
return pushChild.code
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ local function outputToCommit(_, line)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function main(args: {string})
|
function main(args: {string?})
|
||||||
local range = args[1]
|
local range = args[1]
|
||||||
local gitLogChild = process.spawn(
|
local gitLogChild = process.spawn(
|
||||||
"git",
|
"git",
|
||||||
|
|
|
@ -2,7 +2,7 @@ local process = require("@lune/process")
|
||||||
local stdio = require("@lune/stdio")
|
local stdio = require("@lune/stdio")
|
||||||
local task = require("@lune/task")
|
local task = require("@lune/task")
|
||||||
|
|
||||||
local gitLog = require("./gl.luau")
|
local gitLog = require("gl.luau")
|
||||||
type Commit = gitLog.Commit
|
type Commit = gitLog.Commit
|
||||||
|
|
||||||
local function dots(count: number)
|
local function dots(count: number)
|
||||||
|
@ -15,14 +15,16 @@ end
|
||||||
function main(args: {string})
|
function main(args: {string})
|
||||||
print("Unpushed commits:")
|
print("Unpushed commits:")
|
||||||
|
|
||||||
local childExit = gitLog.main({"main..HEAD"})
|
local childExit = gitLog.main({"origin/main..HEAD"})
|
||||||
if childExit ~= 0 then
|
if childExit ~= 0 then
|
||||||
return childExit
|
return childExit
|
||||||
end
|
end
|
||||||
|
|
||||||
stdio.write("Pushing to remote")
|
stdio.write("Pushing to remote")
|
||||||
task.spawn(dots, 3)
|
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
|
if not pushChild.ok then
|
||||||
stdio.ewrite("\r" .. pushChild.stderr)
|
stdio.ewrite("\r" .. pushChild.stderr)
|
||||||
return pushChild.code
|
return pushChild.code
|
||||||
|
|
Loading…
Reference in a new issue