// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "errors" "go.wit.com/lib/config" "go.wit.com/lib/env" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func doCommit() (string, error) { if argv.Commit.All || argv.All || env.True("--all") { // fix this eventually found := me.forge.CheckDirty() var newpatches bool for repo := range found.IterAll() { s := log.Sprintf("%s [git commit --all]", repo.GetNamespace()) setTerminalTitle(s) if err := doCommitRepo(repo); err != nil { return "failed to commit", err } newpatches = true } if newpatches { me.forge.Reload() // check existing repos for changes config.SetChanged("repos", true) return doPatchSubmit() } return "git ommit --all done", nil } repo := findCurrentPwdRepoOrDie() if !repo.CheckDirty() { okExit(log.Sprintf("this repo %s is not dirty.\n\n--all # commit all changes in all repos", repo.GetFullPath())) } else { log.Info("repo is dirty", repo.GetFullPath()) } if repo.GetCurrentBranchName() != repo.GetUserBranchName() { found := new(gitpb.Repos) found.Append(repo) footer := found.PrintDefaultTB() log.Info(footer) log.Info("") log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName()) log.Info("") return "repo must be on user branch", errors.New("repo must be on user branch") } s := log.Sprintf("%s [git commit --all]", repo.GetNamespace()) setTerminalTitle(s) if err := repo.GitCommit(); err != nil { return "git commit --all", err } return doPatchSubmit() } func doCommitRepo(repo *gitpb.Repo) error { if repo.GetCurrentBranchName() != repo.GetUserBranchName() { found := new(gitpb.Repos) found.Append(repo) footer := found.PrintDefaultTB() log.Info(footer) log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName()) log.Info("") return nil } return repo.GitCommit() }