refactor: let updaters define the files they want to run on (#233)

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:
Julian Tölle 2025-08-23 22:14:34 +02:00 committed by GitHub
parent 1e9e0aa5d9
commit f1aa1a2ef4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 307 additions and 151 deletions

View file

@ -8,20 +8,19 @@ import (
)
type updaterTestCase struct {
name string
content string
filename string
info ReleaseInfo
want string
wantErr assert.ErrorAssertionFunc
name string
content string
info ReleaseInfo
want string
wantErr assert.ErrorAssertionFunc
}
func runUpdaterTest(t *testing.T, constructor NewUpdater, tt updaterTestCase) {
func runUpdaterTest(t *testing.T, u Updater, tt updaterTestCase) {
t.Helper()
got, err := constructor(tt.info)(tt.content, tt.filename)
if !tt.wantErr(t, err, fmt.Sprintf("Updater(%v, %v, %v)", tt.content, tt.filename, tt.info)) {
got, err := u.Update(tt.info)(tt.content)
if !tt.wantErr(t, err, fmt.Sprintf("Updater(%v, %v)", tt.content, tt.info)) {
return
}
assert.Equalf(t, tt.want, got, "Updater(%v, %v, %v)", tt.content, tt.filename, tt.info)
assert.Equalf(t, tt.want, got, "Updater(%v, %v)", tt.content, tt.info)
}