blob: 5539c542897da5a50fe13721a30e5165bf7b98c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"go.wit.com/lib/config"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func doCommit() error {
if argv.Commit.All || argv.All {
found := me.forge.CheckDirty()
var newpatches bool
for repo := range found.IterAll() {
log.Info("do a commit on repo", repo.GetNamespace())
if err := doCommitRepo(repo); err != nil {
badExit(err)
}
newpatches = true
}
if newpatches {
me.forge.Reload() // check existing repos for changes
config.SetChanged("repos", true)
return doPatchSubmit()
}
okExit("")
}
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)
me.forge.PrintHumanTable(found)
log.Info("")
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
log.Info("")
okExit("")
}
if err := repo.GitCommit(); err != nil {
badExit(err)
}
return doPatchSubmit()
}
func doCommitRepo(repo *gitpb.Repo) error {
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
found := new(gitpb.Repos)
found.Append(repo)
me.forge.PrintHumanTable(found)
log.Info("")
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
log.Info("")
return nil
}
return repo.GitCommit()
}
|