Apologies - this is a fairly large PR and includes several features - bad practice, I know π
I wanted to submit it anyway and ask for your feedback - if necessary, I can unpick changes later on (and perhaps break into separate PRs, though if possible, I'd prefer to avoid this as it will involve extra work. Let me know, anyway!
I've tested this quite a bit (and also introduced lots more tests) - I think everything works pretty well and makes the plugin a lot more adaptable and powerful. But that's a biased opinion π€£. I'd love it if you would consider merging these.
Here's a summary of the main changes...
Refactoring of changelog generation + new format: 'plain' formatting option. Here's how this looks:
I added a new format: 'plain' option. This was designed to generate the changelog in a format that works nicely with TestFlight (which doesn't support markdown). Here's how the output looks for this:
1.5.1 (2019-11-10)
Features:
- new display_title parameter to hide the header in changelog (https://github.com/abc123)
Bug fixes:
- clean up text strings (https://github.com/abc123)
There are now 3 different options that can be passed into the plugin for formatting:
plain
markdown
slack
While it arguably make more sense for plain to be the default, I didn't want this to be a breaking change, so I've left markdown as the default.
There were 2 large self.markdown and self.slack chunks inside conventional_changelog.rb. As I think you know, these had a lot of duplicated code. I refactored both of them so that all 3 of the format options can use the same logic to generate the changelog. This all lives inside a note_builder method.
As part of this, I created a style_text method which should be extensible in the future, if we wanted to add extra formatting options (e.g. a html option).
Addition of new display_title option for changelog
In some situations, it doesn't make sense to have the version number and title placed at the top of the changelog. That's the case in TestFlight, and also in GitHub. For example, here's how the GH releases page looks for this repo, with the duplicated titles:
I've left the defaults unchanged, but I did introduce a new display_title option. Defaults to true.
If this is set to false, it will remove the title (and newlines) from the top of the changelog. So the output will look a little like this (in plain text mode):
Features:
- new display_title parameter to hide the header in changelog (https://github.com/abc123)
Bug fixes:
- clean up text strings (https://github.com/abc123)
Addition of new display_links option for changelog
Sometimes it doesn't make sense to include the links to the git commits inside the prepared changelog (e.g. in a context which doesn't support them, like TestFlight changelogs).
I've left the defaults unchanged, but I did introduce a new display_links option. Defaults to true.
If this is set to false, it will remove the links from changelog entries. So the output will look a little like this (in plain text mode):
Features:
- new display_title parameter to hide the header in changelog
Bug fixes:
- clean up text strings
Other refactoring
While refactoring changelog generation, I tried to clean up the output as much as possible to remove redundant \n characters in between sections. I also added result.rstrip! to remove any trailing \n characters from the end of the changelog.
I tweaked various typos throughout README and the source.
I tried to expand the documentation a little - I didn't know of a few features myself until I started to try to modify the plugin, so hopefully this will help others! This includes added information about running tests into the documentation.
Apologies - this is a fairly large PR and includes several features - bad practice, I know π
I wanted to submit it anyway and ask for your feedback - if necessary, I can unpick changes later on (and perhaps break into separate PRs, though if possible, I'd prefer to avoid this as it will involve extra work. Let me know, anyway!
I've tested this quite a bit (and also introduced lots more tests) - I think everything works pretty well and makes the plugin a lot more adaptable and powerful. But that's a biased opinion π€£. I'd love it if you would consider merging these.
Here's a summary of the main changes...
Refactoring of changelog generation + new
format: 'plain'
formatting option. Here's how this looks:I added a new
format: 'plain'
option. This was designed to generate the changelog in a format that works nicely with TestFlight (which doesn't support markdown). Here's how the output looks for this:There are now 3 different options that can be passed into the plugin for formatting:
plain
markdown
slack
While it arguably make more sense for
plain
to be the default, I didn't want this to be a breaking change, so I've leftmarkdown
as the default.There were 2 large
self.markdown
andself.slack
chunks insideconventional_changelog.rb
. As I think you know, these had a lot of duplicated code. I refactored both of them so that all 3 of theformat
options can use the same logic to generate the changelog. This all lives inside anote_builder
method.As part of this, I created a
style_text
method which should be extensible in the future, if we wanted to add extra formatting options (e.g. ahtml
option).Addition of new
display_title
option for changelogIn some situations, it doesn't make sense to have the version number and title placed at the top of the changelog. That's the case in TestFlight, and also in GitHub. For example, here's how the GH releases page looks for this repo, with the duplicated titles:
I've left the defaults unchanged, but I did introduce a new
display_title
option. Defaults totrue
.If this is set to
false
, it will remove the title (and newlines) from the top of the changelog. So the output will look a little like this (in plain text mode):Addition of new
display_links
option for changelogSometimes it doesn't make sense to include the links to the git commits inside the prepared changelog (e.g. in a context which doesn't support them, like TestFlight changelogs).
I've left the defaults unchanged, but I did introduce a new
display_links
option. Defaults totrue
.If this is set to
false
, it will remove the links from changelog entries. So the output will look a little like this (in plain text mode):Other refactoring
\n
characters in between sections. I also addedresult.rstrip!
to remove any trailing\n
characters from the end of the changelog.