summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-30 19:16:16 -0500
committerJeff Carr <[email protected]>2025-10-30 19:16:16 -0500
commitdafb9c7028762f0c86499fc3fa557132064d37ec (patch)
treeac80ba738dc48006def47921802e504e89ff6bfd
parent53654740343a08b0df7027e144323750a9960eb7 (diff)
wrong git syntax. more work on publishing
-rw-r--r--argv.go7
-rw-r--r--doGit.go12
-rw-r--r--doPublish.go43
3 files changed, 46 insertions, 16 deletions
diff --git a/argv.go b/argv.go
index 6779cf4..a282112 100644
--- a/argv.go
+++ b/argv.go
@@ -83,6 +83,7 @@ type UpgradeCmd struct {
type PublishCmd struct {
Protobuf bool `arg:"--protobuf" help:"force all protobufs to be republished"`
+ Strict bool `arg:"--strict" help:"run go-mod-clean strict"`
Doit bool `arg:"--doit" help:"actually publish"`
KeepGomod bool `arg:"--keep-gomod" help:"don't really do anything"`
}
@@ -95,7 +96,7 @@ type InstallCmd struct {
type GitCmd struct {
Log *EmptyCmd `arg:"subcommand:log" help:"git log"`
Who *EmptyCmd `arg:"subcommand:who" help:"git who"`
- Tag *EmptyCmd `arg:"subcommand:tag" help:"show tags"`
+ Tag *TagCmd `arg:"subcommand:tag" help:"show tags"`
Pull *EmptyCmd `arg:"subcommand:pull" help:"pull the wit standard paths"`
Push *EmptyCmd `arg:"subcommand:push" help:"push the wit standard paths"`
Template string `arg:"--template" help:"create a new reup from a tempalte"`
@@ -105,5 +106,9 @@ type GitCmd struct {
DeleteUntracked bool `arg:"--delete-untracked" help:"delete the untracked files"`
}
+type TagCmd struct {
+ Delete string `arg:"--delete" help:"what tag to delete"`
+}
+
type EmptyCmd struct {
}
diff --git a/doGit.go b/doGit.go
index b2eaae0..9d4712b 100644
--- a/doGit.go
+++ b/doGit.go
@@ -92,11 +92,21 @@ func doGit() (string, error) {
}
if argv.Git.ChopHEAD != 0 {
- cmd := []string{"git", "reset", "--hard", fmt.Sprintf("HEAD-%d", argv.Git.ChopHEAD)}
+ // tilde here, not a dash
+ cmd := []string{"git", "reset", "--hard", fmt.Sprintf("HEAD~%d", argv.Git.ChopHEAD)}
s, err = runCommand(cmd)
}
if argv.Git.Tag != nil {
+ if argv.Git.Tag.Delete != "" {
+ // git tag --delete v0.3
+ // git push --delete origin v0.3
+ cmd := []string{"git", "tag", "--delete", argv.Git.Tag.Delete}
+ shell.RunVerbose(cmd)
+ cmd = []string{"git", "push", "--delete", "origin", argv.Git.Tag.Delete}
+ shell.RunVerbose(cmd)
+ return "deleted tag", nil
+ }
cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format"}
cmd = append(cmd, "%(tag)%00%(taggerdate:raw)%00%(taggername)%00%(subject)")
cmd = append(cmd, "refs/tags")
diff --git a/doPublish.go b/doPublish.go
index faf17b3..4a3e9a3 100644
--- a/doPublish.go
+++ b/doPublish.go
@@ -23,20 +23,22 @@ func rillRestore(repo *gitpb.Repo) error {
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 argv.Verbose {
- log.Info("go-mod-clean lax START", repo.GetGoPath())
- result := repo.RunRealtime([]string{"go-mod-clean", "lax"})
- log.Info("go-mod-clean lax END", repo.GetGoPath())
- if result.Exit != 0 {
- err = fmt.Errorf("repo %s failed %d", repo.GetGoPath(), result.Exit)
- }
+ if env.Verbose() {
+ _, err = repo.RunQuiet(cmd)
} else {
- _, err = repo.RunQuiet([]string{"go-mod-clean", "lax"})
+ _, err = repo.RunQuiet(cmd)
}
if err != nil {
- log.Info("go-mod-clean lax failed", repo.GetGoPath(), err)
- return err
+ errs := fmt.Sprintf("%v failed (%v)", cmd, err)
+ return errors.New(errs)
}
return nil
}
@@ -45,13 +47,26 @@ func doPublish() error {
initForge()
env.PrintTable()
- me.forge.RillFuncError(rillRestore)
+ log.Printf("Running go-mod-clean on (%d) repos. (1 second per hundred)\n", me.forge.Repos.Len())
+ restored := me.forge.RunOnReposNew(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.RunOnReposNewDumb(me.forge.Repos, rePrepareReleaseNew) // doesn't use Rill()
publish := me.forge.RunOnReposNew(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.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
@@ -60,7 +75,7 @@ func doPublish() error {
}
publish = publish.SortActual()
- footer := publish.PrintPublishNewTB()
+ footer = publish.PrintPublishNewTB()
fmt.Printf("publish.len(%d) PrintPublishTable() footer: %s\n", publish.Len(), footer)
tryme := findNext(publish)
@@ -75,8 +90,8 @@ func doPublish() error {
releaseReason := "new attempt"
- for i, repo := range tryme {
- log.Info("tryme:", i, repo.FullPath)
+ for _, repo := range tryme {
+ log.Printf("tryme: %s reason(%s)", repo.FullPath, repo.State)
gomod, err := os.ReadFile(filepath.Join(repo.FullPath, "go.mod"))
if err != nil {
panic("go.mod missing")