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

Expose API method and CLI command for validating changelog #11

Closed
Gudahtt opened this issue Apr 9, 2021 · 0 comments · Fixed by #28
Closed

Expose API method and CLI command for validating changelog #11

Gudahtt opened this issue Apr 9, 2021 · 0 comments · Fixed by #28
Labels
enhancement New feature or request
Milestone

Comments

@Gudahtt
Copy link
Member

Gudahtt commented Apr 9, 2021

We should explose a CLI command and an API method for validation the changelog. Currently the changelog is validated before it is updated, but we don't have a command yet to just validate.

@Gudahtt Gudahtt added the enhancement New feature or request label Apr 9, 2021
@Gudahtt Gudahtt added this to the v1.0.0 milestone Apr 9, 2021
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Closes #11
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Closes #11
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 20, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 21, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 21, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 21, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 21, 2021
The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11
Gudahtt added a commit that referenced this issue Apr 30, 2021
* Add `validate` command

The validate command will validate the formatting of the changelog.
If the `--rc` flag is used, it will also ensure that the current
version is included as a release header, and that there are no
unreleased changes.

The CLI command displays a rudimentary diff if formatting problems are
detected. This can be improved later with colours, and with
highlighting within each line to show what has changed. It also doesn't
yet highlight whitespace changes.

The validation logic is also exposed via the API as a function called
`validateChangelog`. It doesn't include the fancy diff output, but it
does throw an error with all of the required information for someone to
construct the same output.

Tests have been added to comprehensively test the changelog validation.

Closes #11

* Add additional validation error types

All invalid changelog cases are now described by the
`InvalidChangelogError` error type, which has sub-classes to describe
each possible scenario. This allows distinguishing invalid changelog
errors from all other unexpected errors.

The CLI has been updated to take advantage of this; we now print a
simpler error message if the changelog is invalid, rather than a stack
trace.

* Improve `generateDiff`

The `generateDiff` function now has a comprehensive test suite. It has
been updated to ensure that the resulting diff displays a notice about
whether or not the file has a trailing newline.

I started this journey by trying to ensure we were trimming each line
properly. I found that `diff.diffLines` always returned change sets
that ended in a newline, except when returning the very last change to
a file that didn't terminate in a newline. So in order to ensure we
were correctly showing all changes, I needed to add special handling
for end-of-file changes. We could display this differently than I've
chosen to here, but I figured showing what `git` shows was a good
start.

The `generateDiff` function now also ensures the correct context is
shown in between each change.

The dependency `outdent` was added to help with writing inline test
fixtures. This saves us from having to come up with a name for each
fixture and cross-reference them in each test.

When adding that dependency, an ESLint error brought to my attention
that we were accidentally including test files in our `files` property
in `package.json`. It was updated to exclude test files, which resolved
the ESLint error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant