mirror of
https://github.com/therootcompany/golib.git
synced 2026-03-02 23:57:59 +00:00
fix(monorel): skip repo-root modules; add found binary/module headers
- All three subcommands now print "found binary …" and "found module …" before processing each module group, with a blank line between groups - initModuleGroup, bumpModuleTag, processModule: downgrade the prefix=="" (repository root) case from fatal error to a skip warning so that -recursive runs continue past root-level go.mod packages instead of aborting
This commit is contained in:
parent
e3ada72168
commit
a28fe8ed55
@ -145,7 +145,11 @@ func runRelease(args []string) {
|
||||
fmt.Println("# Generated by monorel — review carefully before running!")
|
||||
fmt.Println("set -euo pipefail")
|
||||
|
||||
for _, group := range groups {
|
||||
for i, group := range groups {
|
||||
if i > 0 {
|
||||
fmt.Fprintln(os.Stderr)
|
||||
}
|
||||
printGroupHeader(cwd, group)
|
||||
relPath, _ := filepath.Rel(cwd, group.root)
|
||||
relPath = filepath.ToSlash(relPath)
|
||||
processModule(group, relPath)
|
||||
@ -206,7 +210,12 @@ func runBump(args []string) {
|
||||
if err != nil {
|
||||
fatalf("%v", err)
|
||||
}
|
||||
for _, group := range groups {
|
||||
cwd, _ := os.Getwd()
|
||||
for i, group := range groups {
|
||||
if i > 0 {
|
||||
fmt.Fprintln(os.Stderr)
|
||||
}
|
||||
printGroupHeader(cwd, group)
|
||||
newTag := bumpModuleTag(group, component, force, dryRun)
|
||||
switch {
|
||||
case newTag == "":
|
||||
@ -259,7 +268,12 @@ func runInit(args []string) {
|
||||
if err != nil {
|
||||
fatalf("%v", err)
|
||||
}
|
||||
for _, group := range groups {
|
||||
cwd, _ := os.Getwd()
|
||||
for i, group := range groups {
|
||||
if i > 0 {
|
||||
fmt.Fprintln(os.Stderr)
|
||||
}
|
||||
printGroupHeader(cwd, group)
|
||||
initModuleGroup(group, dryRun)
|
||||
}
|
||||
}
|
||||
@ -274,7 +288,8 @@ func initModuleGroup(group *moduleGroup, dryRun bool) {
|
||||
prefix := mustRunIn(modRoot, "git", "rev-parse", "--show-prefix")
|
||||
prefix = strings.TrimSuffix(prefix, "/")
|
||||
if prefix == "" {
|
||||
fatalf("%s appears to be the repo root; the module must be in a subdirectory", modRoot)
|
||||
fmt.Fprintf(os.Stderr, "monorel: skip: %s is at the repository root; binaries at the repo root cannot have prefixed tags\n", modRoot)
|
||||
return
|
||||
}
|
||||
prefixParts := strings.Split(prefix, "/")
|
||||
projectName := prefixParts[len(prefixParts)-1]
|
||||
@ -379,7 +394,8 @@ func bumpModuleTag(group *moduleGroup, component string, force, dryRun bool) str
|
||||
prefix := mustRunIn(modRoot, "git", "rev-parse", "--show-prefix")
|
||||
prefix = strings.TrimSuffix(prefix, "/")
|
||||
if prefix == "" {
|
||||
fatalf("%s appears to be the repo root; the module must be in a subdirectory", modRoot)
|
||||
fmt.Fprintf(os.Stderr, "monorel: skip: %s is at the repository root; binaries at the repo root cannot have prefixed tags\n", modRoot)
|
||||
return ""
|
||||
}
|
||||
|
||||
latestStable := findLatestStableTag(modRoot, prefix)
|
||||
@ -653,6 +669,29 @@ func groupByModule(args []string) ([]*moduleGroup, error) {
|
||||
|
||||
// ── Per-module processing ──────────────────────────────────────────────────
|
||||
|
||||
// printGroupHeader writes "found binary …" and "found module …" lines to
|
||||
// stderr before each module is processed, providing progress feedback during
|
||||
// recursive operations.
|
||||
func printGroupHeader(cwd string, group *moduleGroup) {
|
||||
modRel, _ := filepath.Rel(cwd, group.root)
|
||||
modRel = filepath.ToSlash(modRel)
|
||||
for _, bin := range group.bins {
|
||||
suffix := strings.TrimPrefix(bin.mainPath, "./")
|
||||
var binPath string
|
||||
if suffix == "." || suffix == "" {
|
||||
binPath = "./" + modRel
|
||||
} else {
|
||||
binPath = "./" + filepath.ToSlash(filepath.Join(modRel, suffix))
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "found binary %s\n", binPath)
|
||||
}
|
||||
modLabel := "./" + modRel
|
||||
if !strings.HasSuffix(modLabel, "/") {
|
||||
modLabel += "/"
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "found module %s\n", modLabel)
|
||||
}
|
||||
|
||||
// processModule writes .goreleaser.yaml and emits the release-script section
|
||||
// for one module group. relPath is the path from the caller's CWD to the
|
||||
// module root; it is used in the script for all paths so that the script can
|
||||
@ -666,7 +705,8 @@ func processModule(group *moduleGroup, relPath string) {
|
||||
prefix := mustRunIn(modRoot, "git", "rev-parse", "--show-prefix")
|
||||
prefix = strings.TrimSuffix(prefix, "/")
|
||||
if prefix == "" {
|
||||
fatalf("%s appears to be the repo root; the module must be in a subdirectory", modRoot)
|
||||
fmt.Fprintf(os.Stderr, "monorel: skip: %s is at the repository root; binaries at the repo root cannot have prefixed tags\n", modRoot)
|
||||
return
|
||||
}
|
||||
|
||||
prefixParts := strings.Split(prefix, "/")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user