mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
1a69d44d6d
closes #3508 - adds template support for krew and scoop repo refs - template branch on reporef on brew as well Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
37 lines
719 B
Go
37 lines
719 B
Go
package client
|
|
|
|
import (
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
)
|
|
|
|
// RepoFromRef converts a config.RepoRef into a Repo.
|
|
func RepoFromRef(ref config.RepoRef) Repo {
|
|
return Repo{
|
|
Owner: ref.Owner,
|
|
Name: ref.Name,
|
|
Branch: ref.Branch,
|
|
}
|
|
}
|
|
|
|
// TemplateRef templates a config.RepoFromRef
|
|
func TemplateRef(apply func(s string) (string, error), ref config.RepoRef) (config.RepoRef, error) {
|
|
name, err := apply(ref.Name)
|
|
if err != nil {
|
|
return ref, err
|
|
}
|
|
owner, err := apply(ref.Owner)
|
|
if err != nil {
|
|
return ref, err
|
|
}
|
|
branch, err := apply(ref.Branch)
|
|
if err != nil {
|
|
return ref, err
|
|
}
|
|
return config.RepoRef{
|
|
Owner: owner,
|
|
Name: name,
|
|
Token: ref.Token,
|
|
Branch: branch,
|
|
}, nil
|
|
}
|