diff --git a/README.md b/README.md index a0aafb2..f6a8e3f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ To use this plugin you need to include the following block in your | auth_private_key | | The path to an SSH private key file. | | git_path | . | The path to the Git repository. | | push_options | | The push options for the git tag push. | +| tag_prefix | | The tag prefix for the versions. | ### Authentication diff --git a/pkg/provider/git.go b/pkg/provider/git.go index c816043..debcff9 100644 --- a/pkg/provider/git.go +++ b/pkg/provider/git.go @@ -29,6 +29,7 @@ type Repository struct { auth transport.AuthMethod repo *git.Repository pushOptions map[string]string + prefix string } func (repo *Repository) Init(config map[string]string) error { @@ -78,6 +79,10 @@ func (repo *Repository) Init(config map[string]string) error { } } + if config["tag_prefix"] != "" { + repo.prefix = config["tag_prefix"] + } + gitPath := config["git_path"] if gitPath == "" { gitPath = "." @@ -149,10 +154,10 @@ func (repo *Repository) GetReleases(rawRe string) ([]*semrel.Release, error) { err = tags.ForEach(func(reference *plumbing.Reference) error { ref := reference.Name().String() - if !strings.HasPrefix(ref, "refs/tags/") { + if !strings.HasPrefix(ref, "refs/tags/"+repo.prefix) { return nil } - tag := strings.TrimPrefix(ref, "refs/tags/") + tag := strings.TrimPrefix(ref, "refs/tags/"+repo.prefix) if rawRe != "" && !re.MatchString(tag) { return nil } @@ -194,7 +199,7 @@ func (repo *Repository) CreateRelease(release *provider.CreateReleaseConfig) err } hash = resolvedRef.Hash() } - tag := fmt.Sprintf("v%s", release.NewVersion) + tag := fmt.Sprintf("%sv%s", repo.prefix, release.NewVersion) _, err := repo.repo.CreateTag(tag, hash, &git.CreateTagOptions{ Message: release.Changelog, Tagger: &object.Signature{