-
-
Notifications
You must be signed in to change notification settings - Fork 374
make structuredDiffForFile for BitBucketServer the same as the others #1201
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
make structuredDiffForFile for BitBucketServer the same as the others #1201
Conversation
| chunks: | ||
| diff.hunks && | ||
| diff.hunks.map(hunk => ({ | ||
| content: `@@ -${hunk.sourceLine},${hunk.sourceSpan} +${hunk.destinationLine},${hunk.destinationSpan} @@`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Is that too much? https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, that looks right enough to me
| oldStart: hunk.sourceLine, | ||
| oldLines: hunk.sourceSpan, | ||
| newStart: hunk.destinationLine, | ||
| newLines: hunk.destinationSpan, | ||
| changes: hunk.segments | ||
| .map(segment => | ||
| segment.lines.map(line => ({ | ||
| type: segmentValues[segment.type] as "add" | "del" | "normal", | ||
| content: line.line, | ||
| sourceLine: line.source, | ||
| destinationLine: line.destination, | ||
| })) | ||
| ) | ||
| .reduce((a, b) => a.concat(b), []), | ||
| .map(segment => { | ||
| const type = segmentValues[segment.type] | ||
| if (type === "add") { | ||
| return segment.lines.map(line => { | ||
| return { | ||
| type, | ||
| add: true as const, | ||
| content: line.line, | ||
| ln: line.destination, | ||
| } | ||
| }) | ||
| } | ||
| if (type === "del") { | ||
| return segment.lines.map(line => { | ||
| return { | ||
| type, | ||
| del: true as const, | ||
| content: line.line, | ||
| ln: line.source, | ||
| } | ||
| }) | ||
| } | ||
| if (type === "normal") { | ||
| return segment.lines.map(line => { | ||
| return { | ||
| type, | ||
| normal: true as const, | ||
| content: line.line, | ||
| ln1: line.source, | ||
| ln2: line.destination, | ||
| } | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These transformation is based on https://docs.atlassian.com/bitbucket-server/rest/7.19.3/bitbucket-rest.html#idp261
a4e4035 to
dc54972
Compare
|
|
|
Perfect, all this looks great - thanks! |
#1200
structuredDiffForFilefor BitBucketServer the same as the othersanyfromStructuredDiff