Skip to content

Add support for Bitbucket Server imports

Stan Hu requested to merge sh-support-bitbucket-server-import into master

Currently this does the following:

  1. Asks user for the server, username, and password/PAT to login to Bitbucket
  2. Lists the current repositories on Bitbucket server
  3. Clones the repository
  4. Imports pull requests and comments (assuming the commit SHAs exist)

To do:

  1. Add a reconfigure step in case password/personal access token is wrong
  2. Make it possible to handle personal access tokens that have /. Right now URL validation is rejecting these.
  3. For pull requests that are missing commits in the cloned repo, create temporary GitLab branches on Bitbucket Server using API (/rest/api/1.0/projects/project_key/repos/repoSlug/branches). Resync the repository to get these "unreachable" commits. Question: Should this be optional?
  4. Handle errors when password is incorrect/hostname is bad
  5. Handle errors when API response is bad
  6. Add comments when pull request comments are outside of the GitLab diff
  7. Add tests
  8. Add documentation
  9. Test:
    • Pagination

Screenshots

image

image

image

Limitations:

  1. GitLab doesn't allow comments on arbitrary lines of code, so we lose any comments outside of the diff. For now, we'll just insert these as comments in the merge request with file details.
  2. Bitbucket Server allows multiple levels of threading. GitLab import will collapse this into one discussion and quote part of the original comment.
  3. Attachments in Markdown are currently not imported.
  4. Task lists are not imported.
  5. Emoji reactions are not imported (I see no API for this).

Update:

  1. Comments must be retrieved from the activities endpoint: https://community.atlassian.com/t5/Bitbucket-questions/Retrieving-comments-from-Bitbucket-server-via-REST-API/qaq-p/282253

  2. It looks like Bitbucket Server enables the allowReachableSHA1InWant flag in git. We may be able to fetch commits relating to pull requests that have deleted branches. UPDATE: Nope, this doesn't work for our use case. We'll need to create a temporary branch using the Bitbucket Server API.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/25393

Edited by Stan Hu

Merge request reports

Loading