Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to specify multiple version files by comma separated string in conf #65

Merged
merged 1 commit into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rcpr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
[rcpr]
vPrefix = true
releaseBranch = main
versionFile = version.go
versionFile = version.go,action.yml
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
# Often this is a meta-information file such as gemspec, setup.cfg, package.json, etc.
# Sometimes the source code file, such as version.go or Bar.pm, is used.
# If you do not want to use versioning files but only git tags, specify the "-" string here.
# You can specify multiple version files by comma separated strings.
#
# rcpr.vPrefix
# Flag whether or not v-prefix is added to semver when git tagging. (e.g. v1.2.3 if true)
Expand Down
27 changes: 18 additions & 9 deletions rcpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,21 @@ func (rp *rcpr) Run(ctx context.Context) error {
}
nextVer := currVer.GuessNext(labels)

var vfile string
var vfiles []string
if vf := rp.cfg.VersionFile(); vf != nil {
vfile = vf.String()
vfiles = strings.Split(vf.String(), ",")
for i, v := range vfiles {
vfiles[i] = strings.TrimSpace(v)
}
} else {
vfile, err = detectVersionFile(".", currVer)
vfile, err := detectVersionFile(".", currVer)
if err != nil {
return err
}
if err := rp.cfg.SetVersionFile(vfile); err != nil {
return err
}
vfiles = []string{vfile}
}

if com := rp.cfg.Command(); com != nil {
Expand All @@ -209,9 +213,11 @@ func (rp *rcpr) Run(ctx context.Context) error {
rp.c.cmdE(prog, progArgs...)
}

if vfile != "" {
if err := bumpVersionFile(vfile, currVer, nextVer); err != nil {
return err
if vfiles[0] != "" {
for _, vfile := range vfiles {
if err := bumpVersionFile(vfile, currVer, nextVer); err != nil {
return err
}
}
}
rp.c.GitE("add", "-f", rp.cfg.conf) // ignore any errors
Expand Down Expand Up @@ -271,10 +277,13 @@ func (rp *rcpr) Run(ctx context.Context) error {
// Reread the configuration file (.rcpr) as it may have been rewritten during the cherry-pick process.
rp.cfg.Reload()
if rp.cfg.VersionFile() != nil {
vfile = rp.cfg.VersionFile().String()
vfiles = strings.Split(rp.cfg.VersionFile().String(), ",")
for i, v := range vfiles {
vfiles[i] = strings.TrimSpace(v)
}
}
if vfile != "" {
nVer, _ := retrieveVersionFromFile(vfile, nextVer.vPrefix)
if vfiles[0] != "" {
nVer, _ := retrieveVersionFromFile(vfiles[0], nextVer.vPrefix)
if nVer != nil && nVer.Naked() != nextVer.Naked() {
nextVer = nVer
}
Expand Down