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

Add structured diff support to Gitlab #1002

Merged
merged 9 commits into from
Mar 14, 2020
Merged

Add structured diff support to Gitlab #1002

merged 9 commits into from
Mar 14, 2020

Conversation

rohit-gohri
Copy link
Member

Currently gitlab platform doesn't support diffs either through a FullDiff implementation or through structured diffs:

// TODO: implement me when the API methods are in
getFullDiff: async (): Promise<string> => {
throw new Error("getFullDiff is not yet implemented")
},
// TODO: implement me when the API methods are in
getStructuredDiffForFile: async (): Promise<GitStructuredDiff> => {
throw new Error("getStructuredDiffForFile is not yet implemented")
},

Gitlab exposes a full .diff file for merge requests: eg. https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27117.diff
But that only works for public repos, can't access it through API (AFAIK) so not viable to use.

But it's API exposes individual file diffs in Compare API: https://docs.gitlab.com/ce/api/repositories.html#compare-branches-tags-or-commits

The format is a bit different from standard git diff, some things are parsed and removed from it (Open Issue: https://gitlab.com/gitlab-org/gitlab/issues/24913).

So added a function to parse this diff format and create a full diff from it similar to one in danger-ruby:
https://github.com/danger/danger/blob/aa490b4ca59b4b13acaea8f2b11372d06baeec03/lib/danger/request_sources/gitlab.rb#L95-L107

@rohit-gohri
Copy link
Member Author

@jamime @notjosh @bigkraig If either of you could take a look that'll be great!

Copy link
Member

@orta orta left a comment

Choose a reason for hiding this comment

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

I'm into the PR 👍 but I'm a tad worried about how much type safety we lose to make it work

@orta orta merged commit 62a25ba into danger:master Mar 14, 2020
@rohit-gohri rohit-gohri deleted the gitlab-diff branch March 14, 2020 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants