GitHub importer - import and store attachments in GitLab
Release notes
Upon importing projects from GitHub we now import project's image resources and other attachments types - from release notes, comments and notes, issues and PR descriptions. They are added to GitLab's system and their links are updated to new GitLab URLs, so that they not longer link to external sources.
Problem to solve
Upon importing projects from GitHub, image resources are not downloaded and served from GitLab. Instead, just the markup is imported and they will link to external sources for the img src, e.g. on https://cloud.githubusercontent.com/assets/[...]
Ideally, the importer should scrape images and host them in GitLab's system that is used when you attach an image to an issue.
Proposed solution
During import from GitHub, migrate any images to GitLab and update the links in the markdown for these images to the new GitLab URLs.
Links / references
https://gitlab.zendesk.com/agent/tickets/75890
Documentation blurb
- Why should someone use it; what's the underlying problem. Remove a manual task when importing a GitHub project into GitLab.
- What is the solution. Scrape images from GitHub, upload them to GitLab, update links to these images in markdown files.
- How does someone use this This is an automatic feature, or selectable as "experimental".
Technical details
There are couple places where note-like attachments could be inside:
-
Release description (done in GitHub Importer - Import GitHub Release attached files) -
Issue description -
MergeRequest description -
Note text
Also there are cases when pasting image into markdown places it not as markdown element ![image name](http://example.com/image.png)
but as html img tag like <img width="248" alt="image-name" src="http://example.com/image.png">
. So, we need also to:
-
Add support of converting links for src
attribute of<img>
tags inside markdown.