Skip to content

Commit 83f3623

Browse files
authored
reload version file after cherry-picking process (#51)
* reload version file after cherr-picking process
1 parent 5d02379 commit 83f3623

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

config.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func newConfig(gitPath string) (*config, error) {
5151
conf: defaultConfigFile,
5252
gitconfig: &gitconfig.Config{GitPath: gitPath, File: defaultConfigFile},
5353
}
54+
err := cfg.Reload()
55+
return cfg, err
56+
}
5457

58+
func (cfg *config) Reload() error {
5559
if rb := os.Getenv(envReleaseBranch); rb != "" {
5660
cfg.releaseBranch = &configValue{
5761
value: rb,
@@ -85,7 +89,7 @@ func newConfig(gitPath string) (*config, error) {
8589
if vPrefix := os.Getenv(envVPrefix); vPrefix != "" {
8690
b, err := strconv.ParseBool(vPrefix)
8791
if err != nil {
88-
return nil, err
92+
return err
8993
}
9094
cfg.vPrefix = github.Bool(b)
9195
} else {
@@ -94,8 +98,7 @@ func newConfig(gitPath string) (*config, error) {
9498
cfg.vPrefix = github.Bool(b)
9599
}
96100
}
97-
98-
return cfg, nil
101+
return nil
99102
}
100103

101104
func (cfg *config) set(key, value string) error {

rcpr.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ func Run(ctx context.Context, argv []string, outStream, errStream io.Writer) err
337337
}
338338
}
339339

340+
// Reread the configuration file (.rcpr) as it may have been rewritten during the cherry-pick process.
341+
rp.cfg.Reload()
342+
if rp.cfg.VersionFile() != nil {
343+
vfile = rp.cfg.VersionFile().String()
344+
}
340345
if vfile != "" {
341346
nVer, _ := retrieveVersionFromFile(vfile, nextVer.vPrefix)
342347
if nVer != nil && nVer.Naked() != nextVer.Naked() {

0 commit comments

Comments
 (0)