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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// 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"
"strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func doVerify() (string, error) {
if argv.Verify.All {
for r := range me.forge.Repos.IterByFullPath() {
if r.Stats == nil {
doStats(r)
return r.FullPath, nil
}
}
return "verify ran everywhere", nil
}
repo := workingDirToRepo()
if repo == nil {
return "no repo", errors.New("working dir isn't a repo I know about")
}
return doStats(repo)
}
func doStats(r *gitpb.Repo) (string, error) {
var allerr error
pb, err := r.LoadStats()
allerr = errors.Join(allerr, err)
// collect the stats
err = collectStats(r, pb)
allerr = errors.Join(allerr, err)
// build()
return "verify ran", nil
}
func collectStats(r *gitpb.Repo, pb *gitpb.Stats) error {
if hasOrigin(r) {
log.Info("repo doesn't have origin")
}
last100(r)
return nil
}
// git show-ref --verify refs/remotes/origin/HEAD
func hasOrigin(r *gitpb.Repo) bool {
// git show-ref refs/remotes/origin/HEAD
return true
}
var standardFmts []string = []string{"H", "T", "at", "ct", "f"}
var standardSeperator string = "___FORGE___"
func makeFmts() string {
// fmts := strings.Fields(config.GetPanic("standardFmts"))
// fmts := strings.Fields(config.GetPanic("standardSeperator"))
var news []string
for _, fmtvar := range standardFmts {
news = append(news, "%"+fmtvar)
}
return "--format=" + strings.Join(news, standardSeperator)
}
func last100(r *gitpb.Repo) error {
cmd := []string{"git", "log", "-n", "10", makeFmts(), "origin/" + r.GetMasterBranchName()}
log.Info("Run:", cmd)
cmdout := r.Run(cmd)
for i, line := range cmdout.Stdout {
parts := strings.Split(line, standardSeperator)
log.Printf("LINE:%d %v\n", i, parts)
}
return nil
}
|