forge/doCommit.go

42 lines
967 B
Go

// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
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 {
log.Info("todo: forge doesn't know how to work here yet")
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")
}