From 16b25da3964481a6e07e43dda71e5aff030e3656 Mon Sep 17 00:00:00 2001 From: k3nny Date: Tue, 7 Jul 2026 11:58:29 +0200 Subject: [PATCH] feat(config): change default tag_prefix to empty (no prefix) Tags are now bare version numbers by default (e.g. 1.2.3). Set tag_prefix: "v" in .releaser.yml or pass --tag-prefix v to opt in to the v-prefixed convention. Updated all affected tests, the .releaser.yml template comment, and the README configuration reference. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 2 +- cmd/main.go | 2 +- cmd/main_test.go | 22 +++++++++++----------- internal/config/config.go | 2 +- internal/config/config_test.go | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8cd4885..352e14c 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ releaser --branch-pattern "^(?:.*/)?(?:release|hotfix)/(\d+)\.(\d+)$" ```yaml git: - tag_prefix: "v" # set to "" for tags without prefix + tag_prefix: "" # default: no prefix; set to "v" for v-prefixed tags branch_pattern: "^(?:.*/)?release/(\\d+)\\.(\\d+)$" # two capture groups: major, minor commit_message: "chore(release): {version} [skip ci]" author_name: "" # defaults to git config user.name diff --git a/cmd/main.go b/cmd/main.go index 4929d3b..f9bb4df 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -27,7 +27,7 @@ const defaultConfigTemplate = `# .releaser.yml — configuration for git.k3nny.f # CLI flags always take precedence over values set here. git: - # Prefix prepended to every version tag. + # Prefix prepended to every version tag (default: no prefix). # tag_prefix: "v" # Regex that identifies release branches. Must contain exactly two capture diff --git a/cmd/main_test.go b/cmd/main_test.go index c5bd779..5378684 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -228,9 +228,9 @@ func TestRunMissingPom(t *testing.T) { // Tag must still have been created. repo2, _ := gogit.PlainOpen(dir) - _, err = repo2.Tag("v1.2.0") + _, err = repo2.Tag("1.2.0") if err != nil { - t.Error("expected tag v1.2.0 to be created") + t.Error("expected tag 1.2.0 to be created") } } @@ -250,9 +250,9 @@ func TestRunNoPomAtDefaultPath(t *testing.T) { } repo2, _ := gogit.PlainOpen(dir) - _, err = repo2.Tag("v2.0.0") + _, err = repo2.Tag("2.0.0") if err != nil { - t.Error("expected tag v2.0.0 to be created") + t.Error("expected tag 2.0.0 to be created") } } @@ -366,12 +366,12 @@ func TestRunDuplicateTag(t *testing.T) { w.Add("x.go") w.Commit("fix: patch something", &gogit.CommitOptions{Author: testSig()}) - // Pre-create a v1.2.0 ref pointing to a garbage hash. + // Pre-create a 1.2.0 ref pointing to a garbage hash. // LatestTag skips it (resolveTagToCommit fails for garbage hash), - // so run() calculates "v1.2.0" as the first-ever version — then - // CreateTag("v1.2.0") fails because the ref already exists. + // so run() calculates "1.2.0" as the first-ever version — then + // CreateTag("1.2.0") fails because the ref already exists. fakeRef := plumbing.NewHashReference( - plumbing.NewTagReferenceName("v1.2.0"), + plumbing.NewTagReferenceName("1.2.0"), plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), ) if err := repo.Storer.SetReference(fakeRef); err != nil { @@ -380,7 +380,7 @@ func TestRunDuplicateTag(t *testing.T) { err := execCmd(t, "--tag-only", "--no-push", "--branch", "release/1.2", "--repo", dir) if err == nil { - t.Fatal("expected error: v1.2.0 ref already exists") + t.Fatal("expected error: 1.2.0 ref already exists") } } @@ -431,9 +431,9 @@ func TestRunGitLabError(t *testing.T) { func TestRunWithPreviousTag(t *testing.T) { repo, dir := setupRepo(t) - // Tag the initial commit as v1.2.0 (simulates a prior release) + // Tag the initial commit as 1.2.0 (simulates a prior release) initialHead, _ := repo.Head() - repo.CreateTag("v1.2.0", initialHead.Hash(), nil) + repo.CreateTag("1.2.0", initialHead.Hash(), nil) // Fix commit after the tag — run() will use CommitsSince, not AllCommits addFile(t, dir, "x.go", "// fix") diff --git a/internal/config/config.go b/internal/config/config.go index 438b636..2aa306d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -40,7 +40,7 @@ type GitLabConfig struct { func defaults() Config { return Config{ Git: GitConfig{ - TagPrefix: "v", + TagPrefix: "", BranchPattern: branch.DefaultBranchPattern, CommitMessage: "chore(release): {version} [skip ci]", }, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index aa65d6f..e0afc61 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -11,8 +11,8 @@ func TestLoadDefaults(t *testing.T) { if err != nil { t.Fatal(err) } - if cfg.Git.TagPrefix != "v" { - t.Errorf("TagPrefix = %q, want %q", cfg.Git.TagPrefix, "v") + if cfg.Git.TagPrefix != "" { + t.Errorf("TagPrefix = %q, want %q", cfg.Git.TagPrefix, "") } if cfg.Maven.PomPath != "pom.xml" { t.Errorf("PomPath = %q, want %q", cfg.Maven.PomPath, "pom.xml")