Running with --dry-run updates CHANGELOG.md
richtea opened this issue · comments
When running release-it with the --dry-run
option, a reasonable expectation is that no updates would be made to files. However, the keep-a-changelog plugin updates the changelog regardless of the presence of --dry-run
.
There are a couple of solutions I can see - other suggestions welcome!
Option 1
In the standard git plugin, the changelog update is avoided by a bit of a fudge - the git log
command is treated as a write so that the shell exec doesn't get invoked, therefore no changelog is generated. It would be relatively easy to modify this plugin so that it detects global.isDryRun
and doesn't generate a changelog message. That would make this plugin's behaviour consistent with the standard git plugin.
Option 2
Another approach might be to always generate a changelog (including in the standard git plugin, even in dry run mode) but modify the core code so that the changelog update is not performed. This approach has some advantages:
- The changelog could be made visible in interactive mode.
- The change would only need to be made once: otherwise, each changelog plugin needs to add code to support dry run mode explicitly.
- It feels cleaner than treating the
git log
command as a write command.
I'm happy to provide a PR for option 1, as it's fairly easy. I'm not sure I'd be as comfortable implementing option 2 without a fair bit of studying the core code, though.
Oh indeed, I forgot to take this into account when doing this plugin!
Let's take the same approach as the conventional-changelog plugin, and use the global isDryRun
property:
This approach means to do basically as much as possible in the normal flow, except not actually write to the file at the very end. Would you be able to make a PR for this in this repo? If so, thanks in advance!
Sure, I'll get it to you shortly
While I'm creating the PR - would you like me to commit a package-lock.json
and add node-modules to the .gitignore
?
Fixed in #2