mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-07 10:17:02 +00:00
refactor: let updaters define the files they want to run on
This change reverses the responsibility for which files the updaters are run on. Now each updater can specify the list of files and wether the files should be created when they do not exist yet. This simplifies the handling of each update in releaserpleaser.go, as we can just iterate over all updaters and call it for each file of that updater. Also update the flags to allow users to easily define which updaters should run.
This commit is contained in:
parent
1e9e0aa5d9
commit
0cc22af991
20 changed files with 307 additions and 151 deletions
|
|
@ -7,8 +7,26 @@ import (
|
|||
|
||||
var GenericUpdaterSemVerRegex = regexp.MustCompile(`\d+\.\d+\.\d+(-[\w.]+)?(.*x-releaser-pleaser-version)`)
|
||||
|
||||
func Generic(info ReleaseInfo) Updater {
|
||||
return func(content string, filename string) (string, error) {
|
||||
func Generic(files []string) Updater {
|
||||
return generic{
|
||||
files: files,
|
||||
}
|
||||
}
|
||||
|
||||
type generic struct {
|
||||
files []string
|
||||
}
|
||||
|
||||
func (g generic) Files() []string {
|
||||
return g.files
|
||||
}
|
||||
|
||||
func (g generic) CreateNewFiles() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g generic) Update(info ReleaseInfo) func(content string) (string, error) {
|
||||
return func(content string) (string, error) {
|
||||
// We strip the "v" prefix to avoid adding/removing it from the users input.
|
||||
version := strings.TrimPrefix(info.Version, "v")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue