Skip to content

Commit bab1c8d

Browse files
committed
Add --dry-run option
Signed-off-by: Simon Pasquier <[email protected]>
1 parent 74df1ad commit bab1c8d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/bump.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var (
3838
bumpLevel = bumpcmd.Flag("level", "Level of version to increment (should be one of major, minor, patch, pre)").Default("minor").Enum("major", "minor", "patch", "pre")
3939
bumpPreRelease = bumpcmd.Flag("pre-release", "Pre-release identifier").Default("rc.0").String()
4040
bumpBaseBranch = bumpcmd.Flag("base-branch", "Pre-release identifier").Default("master").String()
41+
bumpDryRun = bumpcmd.Flag("dry-run", "Do not modify the files").Bool()
4142
)
4243

4344
type pullRequest struct {
@@ -118,7 +119,7 @@ func writeChangelog(w io.Writer, version string, prs []pullRequest) error {
118119
})
119120
}
120121

121-
func runBumpVersion(changelogPath, versionPath string, bumpLevel string, preRelease string, baseBranch string) error {
122+
func runBumpVersion(changelogPath, versionPath string, bumpLevel string, preRelease string, baseBranch string, dryRun bool) error {
122123
current, err := projInfo.ToSemver()
123124
if err != nil {
124125
return err
@@ -220,6 +221,10 @@ func runBumpVersion(changelogPath, versionPath string, bumpLevel string, preRele
220221
})
221222
}
222223

224+
if dryRun {
225+
return writeChangelog(os.Stdout, next.String(), prs)
226+
}
227+
223228
// Update the changelog file.
224229
original, err := ioutil.ReadFile(changelogPath)
225230
if err != nil {

cmd/promu.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func Execute() {
126126
case checkLicensescmd.FullCommand():
127127
runCheckLicenses(optArg(*checkLicLocation, 0, "."), *headerLength, *sourceExtensions)
128128
case bumpcmd.FullCommand():
129-
err = runBumpVersion("CHANGELOG.md", "VERSION", *bumpLevel, *bumpPreRelease, *bumpBaseBranch)
129+
err = runBumpVersion("CHANGELOG.md", "VERSION", *bumpLevel, *bumpPreRelease, *bumpBaseBranch, *bumpDryRun)
130130
if err != nil {
131131
fatal(err)
132132
}

0 commit comments

Comments
 (0)