Add way to verify each change has associated PRs#222
Merged
Conversation
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| release[category]!.push(description); | ||
| } | ||
| release[category] = releaseCategory; |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the version parameter cannot be a special property name like __proto__, constructor, or prototype. This can be done by adding a validation check for the version parameter before it is used to index into the this.#changes object.
- Add a validation check for the
versionparameter to ensure it is not a special property name. - If the
versionparameter is invalid, throw an error to prevent further execution.
Suggested changeset
1
src/changelog.ts
| @@ -516,2 +516,4 @@ | ||
| throw new Error('Description required'); | ||
| } else if (version !== undefined && (version === '__proto__' || version === 'constructor' || version === 'prototype')) { | ||
| throw new Error(`Invalid version: '${version}'`); | ||
| } else if (version !== undefined && !this.#changes[version]) { |
Copilot is powered by AI and may make mistakes. Always verify output.
Contributor
Author
There was a problem hiding this comment.
I will fix this problem in a new PR since it already exists.
This commit adds a new option to the `validate` command, `--pr-links`, which will cause an error to be thrown if: - a changelog entry does not have one or more links to pull requests after it - a changelog entry does have PR links present, but they do not point to the project's repo - a changelog entry does have PR links present, but they are not positioned at the very end of the line The `ensureValidPrLinksPresent` option has also been added to `validateChangelog`. If this option is provided, then `parseChangelog` is instructed to look for and extract pull request numbers from changelog entries. The list of numbers will then be checked for in the validation step. It is also used to reconstruct pull request links when the changelog is stringified. Note that because this commit changes what `parseChangelog` returns, this is a breaking change.
cba716b to
803ae97
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a new option to the
validatecommand,--pr-links, which will cause an error to be thrown if:The
ensureValidPrLinksPresentoption has also been added tovalidateChangelog.If this option is provided, then
parseChangelogis instructed to look for and extract pull request numbers from changelog entries. The list of numbers will then be checked for in the validation step. It is also used to reconstruct pull request links when the changelog is stringified.Note that because this commit changes what
parseChangelogreturns, this is a breaking change.Closes #150.
Changelog
Added
--pr-links/--prLinksto thevalidatecommandensureValidPrLinksPresenttovalidateChangelogshouldExtractPrLinkstoparseChangelogwhich, if true, will attempt to look for and extract PR links/numbers from each changelog entry.prNumberstoChangelog.addChange, which will be combined with the description when the changelog is stringified.Changed
Changelog.getReleaseChangesandChangelog.getUnreleasedChangesnow return an array of objects ({ description, prNumbers }) rather than array of strings.Manual testing
yarn buildyarn run changelog validate --pr-links. This will validate this package's changelog, checking for PR links.yarn run changelog validate --pr-linksagain.yarn run changelog validate --pr-linksagain.