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

Fix GitJSONDSL and diffForFile for BitBucket Server #764

Merged
merged 1 commit into from
Nov 15, 2018
Merged

Fix GitJSONDSL and diffForFile for BitBucket Server #764

merged 1 commit into from
Nov 15, 2018

Conversation

langovoi
Copy link
Contributor

@langovoi langovoi commented Nov 14, 2018

Bitbucket Server API for diff sometimes return truncated: true in root of response.
This means that Bitbucket Server don't provide full diff of all files.

In my practical with Danger, this breaks modified_files, created_files and deleted_files.

Bitbucket Server has another API, which returns list of changes in PR, without diff.
I replaced diff API with changes API for generation GitJSONDSL.

Also I reworked diffForFile to fix potential bug with Bitbucket Server, when diff API may return truncated results.

@langovoi langovoi requested a review from orta November 14, 2018 19:30
@langovoi
Copy link
Contributor Author

langovoi commented Nov 14, 2018

@orta could you review, please?


values = values.concat(data.values)
nextPageStart = data.nextPageStart
} while (nextPageStart !== null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collect all pages with changes

@@ -3,7 +3,7 @@ import { dangerSignaturePostfix } from "../../../runner/templates/bitbucketServe

describe("API testing - BitBucket Server", () => {
let api: BitBucketServerAPI
let jsonResult: any
let jsonResult: () => any
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing to set jsonResult as function. For example for use jest.fn

nextPageStart: 1,
values: ["1"],
})
.mockReturnValueOnce({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulate iteration by pages

@orta
Copy link
Member

orta commented Nov 15, 2018

OK, cool, yeah this looks good 👍

@orta orta merged commit 0afefa8 into danger:master Nov 15, 2018
@langovoi langovoi deleted the bitbucket-diff branch November 15, 2018 11:38
@langovoi
Copy link
Contributor Author

Great! Could you make new release, please?

@orta
Copy link
Member

orta commented Nov 15, 2018

Yep, this came out in 6.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants