Github Importer: thread diff notes
Problem statement
When importing a project from Github it imports merge requests diff notes, comments associated with a file diff, in a non-threaded way.
Github | Gitlab |
---|---|
Proposed solution
Each diff note is created by Gitlab::GithubImport::Importer::DiffNoteImporter
, which fetches the data from Github's List review comments in a repository API. This documentation mentions that each diff note provides a in_reply_to_id
, which can be used to create Gitlab discussions.
Implementation details
- When the
in_reply_to_id
is empty- Create a new
discussion_id
- Map the
pull_request_comment.id
to thediscussion_id
created on redis (Github original id for the diff note). Example:8 -> f9f509e301c2ff6112a365ca066cda63c183530c
, where:-
8
is the original github id for the diff note; -
f9f509e301c2ff6112a365ca066cda63c183530c
is thediscussion_id
;
-
- Create a new
- When the
in_reply_to_id
has a value- Use the github_id->discussion_id map to find the discussion id related to the
in_reply_to_id
; - Use the found
discussion_id
on the new diff note; - Add another entry to the github_id->discussion_id map to map the new diff note to the discussion_id, like
9 -> f9f509e301c2ff6112a365ca066cda63c183530c
;
- Use the github_id->discussion_id map to find the discussion id related to the
- Currently there's no documentation wether the GithubImporter imports or not threaded notes, therefore an update on the documentation must be done (https://docs.gitlab.com/ee/user/project/import/github.html#import-your-project-from-github-to-gitlab);
- Example of implementation https://gitlab.com/gitlab-org/gitlab/-/compare/master...githb-importer-threaded-diff-notes-proposal
Expected Result
Related Documentation
- Update the User documentation https://docs.gitlab.com/ee/user/project/import/github.html
- Update the Developer documentation https://docs.gitlab.com/ee/development/github_importer.html
Edited by Kassio Borges