Skip to content

Bitbucket Cloud: Safe handling of issue refs

Madelein van Niekerk requested to merge 412614-safe-issue-ref-conversion into master

What does this MR do and why?

When notes are imported from Bitbucket, it can contain references (links) to MRs, issues, etc. but these point to the Bitbucket urls so it's not useful. We therefore convert the refs to gitlab refs.

There is one case that was missed: when the link is for issues but not a specific issue e.g. https://gitlab.com/gitlab-org/gitlab/-/issues. This MR fixes that by updating the regex to look for issue names instead of values after the last backslash. A spec was also added to test this.

This happened 51 times in the last 7 days (ref)

How to set up and validate locally

  1. Follow https://docs.gitlab.com/ee/integration/bitbucket.html to setup OAuth for BitBucket Cloud. You will need an account on https://bitbucket.org/ that uses the same email address as the account on the gdk instance. You may need to create a new user on the gdk for this.
  2. Make sure you add the bitbucket configuration in the development section of your config/gitlab.yml as shown at https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/gitlab-oauth2.md#set-up-gdk:
    development:
      <<: *base
      omniauth:
        providers:
        - { name: 'bitbucket',
            app_id: '...',
            app_secret: '...' }
  3. Log into the gdk with the relevant user credentials and in ...-/profile/account connect bitbucket there:
  1. Create a project and repo on BitBucket. Create an MR and add a note with a reference to issues https://bitbucket.org/<project>/<repo>/issues and specific issues.
  2. Enable the feature flag: Feature.enable(:bitbucket_parallel_importer)
  3. On your gdk instance, create a new project > click on Import project > Bitbucket Cloud > follow instructions to connect to https://bitbucket.org/.
  4. Import the project.
  5. Verify that the refs in the notes were successfully converted to gitlab refs.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #412614 (closed)

Edited by Madelein van Niekerk

Merge request reports