forge/doCommit.go

39 lines
855 B
Go
Raw Normal View History

2025-01-20 01:47:27 -06:00
package main
import (
"os"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func doCommit() {
pwd, _ := os.Getwd()
repo := me.forge.Repos.FindByFullPath(pwd)
if repo == nil {
2025-01-29 01:12:44 -06:00
log.Info("todo: forge doesn't know how to work here yet")
2025-01-20 01:47:27 -06:00
okExit("")
}
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
me.found.Append(repo)
me.forge.PrintHumanTable(me.found)
log.Info("")
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
log.Info("")
okExit("")
}
os.Setenv("LESS", "-XR")
if err := shell.Exec([]string{"git", "diff"}); err != nil {
badExit(err)
}
if argv.All {
if err := shell.ExecCheck([]string{"git", "add", "--all"}); err != nil {
badExit(err)
}
}
if err := shell.ExecCheck([]string{"git", "commit", "--all"}); err != nil {
badExit(err)
}
log.Info("git commit ok. forge done")
}