summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go4
-rw-r--r--doFix.deleteuser.go23
-rw-r--r--doStats.go66
3 files changed, 69 insertions, 24 deletions
diff --git a/argv.go b/argv.go
index 9ee7460..67dfcef 100644
--- a/argv.go
+++ b/argv.go
@@ -62,8 +62,8 @@ type FixCmd struct {
}
type VerifyCmd struct {
- List bool `arg:"--list" help:"list all stats"`
- All bool `arg:"--all" help:"do all repos"`
+ All *EmptyCmd `arg:"subcommand:all" help:"show mtime changes"`
+ List bool `arg:"--list" help:"list all stats"`
}
func (ShowCmd) Examples() string {
diff --git a/doFix.deleteuser.go b/doFix.deleteuser.go
index 991f886..6247be5 100644
--- a/doFix.deleteuser.go
+++ b/doFix.deleteuser.go
@@ -42,7 +42,11 @@ func doDeleteUser() (string, error) {
continue
}
}
- doFixDeleteUserBranches(repo, uremoteref)
+ err := doFixDeleteUserBranches(repo, uremoteref)
+ if err == nil {
+ return "might have worked?", nil
+ }
+ log.Info("doFixDeleteUserBranches() probably didn't delete it either", err)
}
me.forge.PrintHumanTable(found)
return "TODO: CHECK git patchId to verify these", nil
@@ -334,8 +338,6 @@ func doFixDeleteLocalUserByMaster(repo *gitpb.Repo, localRef *gitpb.GitTag) (err
// todo: these names are all horrible
// delete localRef if it's completely contained in the masterRef
func safeDelete(repo *gitpb.Repo, deleteHash string, keepHash string) error {
- notes := new(notesList)
-
// compare the branches
hashok, hashbad, cmd1, cmd2, err := repo.CompareHashes(keepHash, deleteHash)
@@ -348,20 +350,17 @@ func safeDelete(repo *gitpb.Repo, deleteHash string, keepHash string) error {
// things only in the master branch (safe to ignore)
for _, line := range hashok {
- notes.addTextNote("OK", repo, "in keepHash", cmd1, line)
+ parts := strings.Split(line, "%00") // git log doesn't actually convert %00 to NULL
+ log.Printf("%-13.13s %-55.55s %v\n", "OK delete", repo.FullPath, parts)
}
+ if len(hashbad) > 0 {
+ log.Printf("%-13.13s %-55.55s %v\n", "BAD cmd", repo.FullPath, cmd1)
+ }
// things still only in the local branch (bad to delete)
for _, line := range hashbad {
- // notes.addTextNote("BAD", repo, localRef.GetRef(), cmd2, line)
- notes.addTextNote("BAD", repo, "in deleteHash", cmd2, line)
parts := strings.Split(line, "%00") // git log doesn't actually convert %00 to NULL
- if len(parts) != 4 {
- log.Info("len", len(parts))
- panic("nope")
- }
- findThisHash := parts[0]
- log.Info(findThisHash, deleteHash, "need to figure out the patchID for this to be deleted hash")
+ log.Printf("%-13.13s %-55.55s %v\n", "BAD keep", repo.FullPath, parts)
}
if len(hashbad) == 0 {
diff --git a/doStats.go b/doStats.go
index 04ad1f4..38ceb15 100644
--- a/doStats.go
+++ b/doStats.go
@@ -15,11 +15,12 @@ import (
)
func doVerify() (string, error) {
- if argv.Verify.All {
+ var allerr error
+ if argv.Verify.All != nil {
for r := range me.forge.Repos.IterByFullPath() {
if r.Stats == nil {
- doStats(r)
- return r.FullPath, nil
+ _, err := doStats(r)
+ allerr = errors.Join(allerr, err)
}
}
return "verify ran everywhere", nil
@@ -30,26 +31,52 @@ func doVerify() (string, error) {
return "no repo", errors.New("working dir isn't a repo I know about")
}
- return doStats(repo)
+ s, err := doStats(repo)
+ allerr = errors.Join(allerr, err)
+
+ user, err := refHash(repo, "heads/jcarr")
+ allerr = errors.Join(allerr, err)
+ master, err := refHash(repo, "remotes/origin/master")
+ allerr = errors.Join(allerr, err)
+ HEAD, err := refHash(repo, "remotes/origin/HEAD")
+ allerr = errors.Join(allerr, err)
+ log.Printf("user=%10.10s master=%10.10s HEAD=%10.10s\n", user, master, HEAD)
+ safeDelete(repo, user, HEAD) // delete user if safely contained in HEAD
+
+ return s, allerr
}
func doStats(r *gitpb.Repo) (string, error) {
var allerr error
pb, err := r.LoadStats()
+ if err == nil {
+ log.Info("LoadStats() ok", pb.Filename)
+ } else {
+ log.Info("LoadStats() err", err)
+ }
allerr = errors.Join(allerr, err)
if hasOrigin(r) {
- log.Info("repo doesn't have origin")
+ log.Info("todo: detect origin")
}
// collect the stats
counter, err := last100(r, pb)
allerr = errors.Join(allerr, err)
s := log.Sprintf("found %d new hashes", counter)
- if counter > 0 {
- pb.Save()
+
+ for stat := range pb.IterAll() {
+ if stat.PatchId == "" {
+ stat.PatchId, err = r.FindPatchIdByHash(stat.Hash)
+ allerr = errors.Join(allerr, err)
+ log.Info("patchid for hash", stat.Hash, "is", stat.PatchId)
+ counter += 1
+ }
}
+ if counter > 0 {
+ pb.SaveVerbose()
+ }
// build()
return s, nil
}
@@ -58,9 +85,28 @@ func collectStats(r *gitpb.Repo, pb *gitpb.Stats) error {
return nil
}
-// git show-ref --verify refs/remotes/origin/HEAD
+// git show-ref refs/heads/devel
+func refHash(r *gitpb.Repo, name string) (string, error) {
+ var hash string
+ refname := "refs/" + name
+ cmd := []string{"git", "show-ref", refname}
+ cmdout := r.Run(cmd)
+ for i, line := range cmdout.Stdout {
+ parts := strings.Fields(line)
+ if config.If("stats") {
+ log.Info(parts[0], "LINE:", i, line)
+ }
+ hash = parts[0]
+ }
+ if len(cmdout.Stdout) != 1 {
+ return "", errors.New("no refname:" + name)
+ }
+ return hash, nil
+}
+
+// git show-ref --verify refs/heads/devel
func hasOrigin(r *gitpb.Repo) bool {
- // git show-ref refs/remotes/origin/HEAD
+ // git show-ref refs/heads/devel
return true
}
@@ -80,7 +126,7 @@ func makeFmts() string {
func last100(r *gitpb.Repo, pb *gitpb.Stats) (int, error) {
var allerr error
var counter int
- cmd := []string{"git", "log", "-n", "10", makeFmts(), "origin/" + r.GetMasterBranchName()}
+ cmd := []string{"git", "log", "-n", "100", makeFmts(), "origin/" + r.GetMasterBranchName()}
if config.If("stats") {
log.Info("Run:", cmd)
}