// 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 // collect the stats err := collectStats(r) allerr = errors.Join(allerr, err) // build() return "verify ran", nil } func collectStats(r *gitpb.Repo) error { if r.Stats == nil { r.Stats = new(gitpb.Stats) } 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 }