Skip to content

Commit d73bffe

Browse files
authored
fix: add multi-module flags to tag subcommands (#259)
* fix: add multi-module flags to tag subcommands Move MultiModuleFlags to create, list, and push subcommands. Remove -m alias from --message on create to avoid conflict with --module alias.
1 parent 9cfc9a2 commit d73bffe

13 files changed

Lines changed: 42 additions & 36 deletions

File tree

internal/commands/discover/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (w *Workflow) runInitWorkflow(ctx context.Context) (bool, error) {
9696

9797
// Check if we have useful suggestions
9898
if len(w.result.SyncCandidates) == 0 && len(w.result.Modules) == 0 {
99-
// No .version files found check for monorepo workspace markers
99+
// No .version files found - check for monorepo workspace markers
100100
// (go.work, pnpm-workspace.yaml, package.json workspaces, Cargo.toml [workspace])
101101
if monoInfo, err := initialize.DetectMonorepo(); err == nil && monoInfo != nil {
102102
return w.runMonorepoInitWorkflow(ctx, monoInfo)

internal/commands/initialize/detection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func detectCargoWorkspace() (*MonorepoInfo, error) {
300300
continue
301301
}
302302

303-
// New section starts stop if we were in [workspace]
303+
// New section starts - stop if we were in [workspace]
304304
if strings.HasPrefix(line, "[") && line != "[workspace]" {
305305
if inWorkspace {
306306
break

internal/commands/initialize/detection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ func TestDetectMonorepo_Priority(t *testing.T) {
566566
tmpDir := t.TempDir()
567567
t.Chdir(tmpDir)
568568

569-
// Both go.work and pnpm-workspace.yaml present go.work should win
569+
// Both go.work and pnpm-workspace.yaml present - go.work should win
570570
writeTestFile(t, "go.work", "go 1.21\nuse ./mod1\n")
571571
mkdirTest(t, "mod1")
572572
writeTestFile(t, "pnpm-workspace.yaml", "packages:\n - \"packages/*\"\n")

internal/commands/tag/tagcmd.go

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,24 @@ func Run(cfg *config.Config) *cli.Command {
5454

5555
// createCmd returns the "tag create" subcommand.
5656
func (tc *TagCommand) createCmd(cfg *config.Config) *cli.Command {
57+
flags := []cli.Flag{
58+
&cli.BoolFlag{
59+
Name: "push",
60+
Usage: "Push the tag to remote after creation",
61+
},
62+
&cli.StringFlag{
63+
Name: "message",
64+
Usage: "Override the tag message (for annotated/signed tags)",
65+
},
66+
}
67+
flags = append(flags, cliflags.MultiModuleFlags()...)
68+
5769
return &cli.Command{
5870
Name: "create",
5971
Aliases: []string{"c", "new"},
6072
Usage: "Create a git tag for the current version",
61-
UsageText: "sley tag create [--push] [--message <msg>]",
62-
Flags: []cli.Flag{
63-
&cli.BoolFlag{
64-
Name: "push",
65-
Usage: "Push the tag to remote after creation",
66-
},
67-
&cli.StringFlag{
68-
Name: "message",
69-
Aliases: []string{"m"},
70-
Usage: "Override the tag message (for annotated/signed tags)",
71-
},
72-
},
73+
UsageText: "sley tag create [--push] [--message <msg>] [--all] [--module name]",
74+
Flags: flags,
7375
Action: func(ctx context.Context, cmd *cli.Command) error {
7476
return tc.runCreateCmd(ctx, cmd, cfg)
7577
},
@@ -78,19 +80,22 @@ func (tc *TagCommand) createCmd(cfg *config.Config) *cli.Command {
7880

7981
// listCmd returns the "tag list" subcommand.
8082
func (tc *TagCommand) listCmd(cfg *config.Config) *cli.Command {
83+
flags := []cli.Flag{
84+
&cli.IntFlag{
85+
Name: "limit",
86+
Aliases: []string{"n"},
87+
Usage: "Limit the number of tags shown",
88+
Value: 0,
89+
},
90+
}
91+
flags = append(flags, cliflags.MultiModuleFlags()...)
92+
8193
return &cli.Command{
8294
Name: "list",
8395
Aliases: []string{"l", "ls"},
8496
Usage: "List existing version tags",
85-
UsageText: "sley tag list [--limit <n>]",
86-
Flags: []cli.Flag{
87-
&cli.IntFlag{
88-
Name: "limit",
89-
Aliases: []string{"n"},
90-
Usage: "Limit the number of tags shown",
91-
Value: 0,
92-
},
93-
},
97+
UsageText: "sley tag list [--limit <n>] [--all] [--module name]",
98+
Flags: flags,
9499
Action: func(ctx context.Context, cmd *cli.Command) error {
95100
return tc.runListCmd(ctx, cmd, cfg)
96101
},
@@ -103,7 +108,8 @@ func (tc *TagCommand) pushCmd(cfg *config.Config) *cli.Command {
103108
Name: "push",
104109
Aliases: []string{"p"},
105110
Usage: "Push a tag to remote",
106-
UsageText: "sley tag push [tag-name]",
111+
UsageText: "sley tag push [tag-name] [--all] [--module name]",
112+
Flags: cliflags.MultiModuleFlags(),
107113
Action: func(ctx context.Context, cmd *cli.Command) error {
108114
return tc.runPushCmd(ctx, cmd, cfg)
109115
},

internal/git/git_error_recovery_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestUpdateRepo_NonExistentRepo(t *testing.T) {
129129
// TestCloneOrUpdate_UpdateError tests error propagation when update fails.
130130
func TestCloneOrUpdate_UpdateError(t *testing.T) {
131131
t.Parallel(
132-
// Create a repo with no remote configured git pull will fail
132+
// Create a repo with no remote configured - git pull will fail
133133
)
134134

135135
sourceRepo := setupTestRepo(t)

internal/git/ref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func SafeFallbackSince(execCommand func(string, ...string) *exec.Cmd, n int) str
2525
return fmt.Sprintf("HEAD~%d", n)
2626
}
2727

28-
// Fewer than n commits use the root commit so the range covers everything.
28+
// Fewer than n commits - use the root commit so the range covers everything.
2929
root := execCommand("git", "rev-list", "--max-parents=0", "HEAD")
3030
rootOut, err := root.Output()
3131
if err != nil {

internal/pathutil/pathutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func resolveSymlinks(absBase, absPath string) (string, string) {
2828
return resolvedBase, filepath.Join(resolvedParent, filepath.Base(absPath))
2929
}
3030

31-
// Cannot resolve path side fall back to both unresolved to avoid mismatch
31+
// Cannot resolve path side - fall back to both unresolved to avoid mismatch
3232
return absBase, absPath
3333
}
3434

internal/plugins/changeloggenerator/generator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,15 @@ func moduleNameFromPath(changesDir, filePath string) string {
519519
}
520520

521521
// prefixVersionHeading injects a module name into the first ## heading of
522-
// changelog content. "## v0.1.0 - date" becomes "## <module> v0.1.0 - date".
522+
// changelog content. "## v0.1.0 - date" becomes "## <module> - v0.1.0 - date".
523523
// If no ## heading is found, the content is returned unchanged.
524524
func prefixVersionHeading(content, moduleName string) string {
525525
const h2 = "## "
526526
before, after, ok := strings.Cut(content, h2)
527527
if !ok {
528528
return content
529529
}
530-
return before + h2 + moduleName + " " + after
530+
return before + h2 + moduleName + " - " + after
531531
}
532532

533533
// MergeVersionedFiles merges all versioned changelog files into a unified CHANGELOG.md.

internal/plugins/changeloggenerator/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (g *GitOps) getCommitsWithMeta(since, until string) ([]CommitInfo, error) {
101101
if since == "" {
102102
lastTag, err := g.getLatestTag()
103103
if err != nil {
104-
// No tags found fall back to a safe recent range.
104+
// No tags found - fall back to a safe recent range.
105105
// Use HEAD~10 if enough commits exist, otherwise use the repo root.
106106
since = git.SafeFallbackSince(g.ExecCommandFn, 10)
107107
} else {

internal/plugins/changeloggenerator/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (p *ChangelogGeneratorPlugin) writeChangelog(version, content string) error
149149
mode := p.config.Mode
150150

151151
// For unified mode with module context, inject the module name into the
152-
// version heading: "## v0.1.0 - date" becomes "## <module> v0.1.0 - date"
152+
// version heading: "## v0.1.0 - date" becomes "## <module> - v0.1.0 - date"
153153
unifiedContent := content
154154
if p.moduleName != "" {
155155
unifiedContent = prefixVersionHeading(content, p.moduleName)

0 commit comments

Comments
 (0)