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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// 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"
"fmt"
"os"
"path/filepath"
"go.wit.com/lib/env"
"go.wit.com/lib/protobuf/argvpb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func rillRestore(repo *gitpb.Repo) error {
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
return nil
}
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
return nil
}
cmd := []string{"go-mod-clean", "lax"}
if env.True("--strict") {
cmd = []string{"go-mod-clean", "purge"}
repo.RunQuiet(cmd)
cmd = []string{"go-mod-clean", "--restore"}
}
var err error
if env.Verbose() {
_, err = repo.RunQuiet(cmd)
} else {
_, err = repo.RunQuiet(cmd)
}
if env.True("--strict") {
cmd = []string{"go-mod-clean", "strict"}
_, err = repo.RunQuiet(cmd)
}
if err != nil {
errs := fmt.Sprintf("%v failed (%v)", cmd, err)
return errors.New(errs)
}
return nil
}
// fuck you prior self. this code is garbage
// nevermind, I knew that when I wrote it.
// I'm back now to fix it. Thank you for making it work until I got back here
// shame you aren't as smart as fabrice. you might have done this on the first go around
// fine though, you have different talents. Also, Mariam loves you.
func doPublish() error {
initForge()
env.PrintTable()
log.Printf("Running go-mod-clean on (%d) repos. (1 second per hundred)\n", me.forge.Repos.Len())
restored := me.forge.RunOnRepos(me.forge.Repos, rillRestore)
restored = restored.SortActual()
footer := restored.PrintPublishNewTB()
fmt.Printf("restored.len(%d) with errors: %s\n", restored.Len(), footer)
// publish := me.forge.RunOnReposSlow(me.forge.Repos, rePrepareReleaseNew) // doesn't use Rill()
publish := me.forge.RunOnRepos(me.forge.Repos, rePrepareReleaseNew)
if publish == nil {
return errors.New("nothing to publish. you actually have to write code first")
}
for repo := range publish.IterAll() {
err := me.forge.CheckUpdatingGoDeps(repo.GoInfo.GoDeps, publish)
if err != nil {
repo.State = fmt.Sprintf("%s err (%v)\n", repo.Namespace, err)
} else {
cmd := []string{"go-mod-clean", "strict"}
repo.RunRealtime(cmd)
}
}
for repo := range publish.IterAll() {
// update the target version
// repo.IncrementTargetMinor()
repo.IncrementTargetRevision()
}
publish = publish.SortActual()
footer = publish.PrintPublishNewTB()
fmt.Printf("publish.len(%d) PrintPublishTable() footer: %s\n", publish.Len(), footer)
tryme := findNext(publish)
if len(tryme) == 0 {
return errors.New("can't find something safe to publish")
}
startRepo := me.forge.Repos.FindByNamespace("go.wit.com/lib/xgb")
if startRepo == nil {
return errors.New("a startRepo can't be found")
}
releaseReason := "new attempt"
for _, repo := range tryme {
log.Printf("tryme: %s reason(%s)\n", repo.FullPath, repo.State)
gomod, err := os.ReadFile(filepath.Join(repo.FullPath, "go.mod"))
if err != nil {
panic("go.mod missing")
}
log.Info(string(gomod))
if env.True("--doit") {
log.Printf("RUNNING: doRelease(%s, %s, %s) %s\n", repo.Namespace, startRepo.Namespace, releaseReason, repo.GetTargetVersion())
err := doRelease(repo, startRepo, releaseReason)
if err != nil {
return err
}
} else {
log.Printf("WOULD HAVE RUN: doRelease(%s, %s, %s) %s\n", repo.Namespace, startRepo.Namespace, releaseReason, repo.GetTargetVersion())
}
}
for _, repo := range tryme {
log.Printf("tryme: %s reason(%s)\n", repo.FullPath, repo.State)
}
if !env.True("--doit") {
return errors.New("run with --doit to actually try to publish")
}
argvpb.GoodExit("PUBLISH WORKED")
return nil
}
|