Skip to content

Commit

Permalink
Fix semver check on version range for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Bento committed Jun 8, 2019
1 parent 35af1e7 commit 7d2300a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/components/common/Diff/DiffComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,29 @@ const getLineNumberWithType = ({ lineChangeType, lineNumber }) =>

const getComments = ({ newPath, fromVersion, toVersion }) => {
const newPathSanitized = removeAppPathPrefix(newPath)
const cleanedToVersion = semver.valid(semver.coerce(toVersion))

const versionsInDiff = releasedVersions.filter(
({ version, comments }) =>
(semver.lt(version, toVersion) || semver.gt(version, fromVersion)) &&
semver.lte(version, cleanedToVersion) &&
semver.gt(version, fromVersion) &&
comments.some(({ fileName }) => fileName === newPathSanitized)
)

return versionsInDiff.reduce((allComments, version) => {
const comments = version.comments.reduce(
(versionComments, { lineChangeType, lineNumber, content }) => ({
...versionComments,
[getLineNumberWithType({ lineChangeType, lineNumber })]: (
<DiffComment content={content} />
)
}),
(versionComments, { fileName, lineChangeType, lineNumber, content }) => {
if (fileName !== newPathSanitized) {
return versionComments
}

return {
...versionComments,
[getLineNumberWithType({ lineChangeType, lineNumber })]: (
<DiffComment content={content} />
)
}
},
{}
)

Expand Down

0 comments on commit 7d2300a

Please sign in to comment.