Import GitHub Gists as GitLab Snippets
### Problem to solve We can import repos from GitHub, but for a more complete migration away from GitHub, we would need to have a way to import GitHub Gists as well. With the release of [Snippets with multiple Files](https://gitlab.com/gitlab-org/gitlab/-/issues/14340), it is now possible to migrate GitHub Gists (up to 10 files) directly into GitLab Snippets. As we haven't had any requests to increase that limit in the product and allow snippets to have more files, we won't try to make that possible with import either. ### Proposal Enable a one-time bulk import of personal gists [created by the person](https://docs.github.com/en/rest/gists/gists#list-gists-for-the-authenticated-user) into [their personal GitLab Snippets](https://docs.gitlab.com/ee/user/snippets.html#create-snippets) visible on [Snippets Dashboard](https://gitlab.com/dashboard/snippets): * public gists become public visibility level snippets * secret gists become private visibility level snippets. In case of gists with multiple files, in the first iteration we: * skip the import of anything larger than 10 files * log an error when a gist import has to be skipped in a way we can query the frequency * document this limit and encourage customers to manually migrate these rare gists over to projects. Later: * let the customer know which gists were skipped or didn't import because of other reasons (needs some UX input) #### Project snippets Next to personal snippets GitLab provides **project snippets**, however: - as GitHub doesn't have such feature we shouldn't artificially create it during the import - GitHub gists are linked to the user, not to the organisation. Therefore, they can contain private user information. Importing user gists from all team members as Gitlab project-level snippets could lead to a leak of private user information. ### Notes GitHub gists can be public or secret (not searchable, but not private). GitLab provides two types of snippets: * Personal snippets - created independent of any project, that can have public or private visibility level * Project snippets - always related to a specific project. Project snippets can be visible publicly, or to only project members. Gists have description (optional) and filenames for files (required), but there's no name/title for a gist. Snippets have title (required) and description (optional). If gist description is present, we use it as the snippet title (attention: Gist description has a limit of 256, while the snippet's title can be up to 255). If gist description is missing we use the file name (filename of the first file, if there are multiple files) as a snippet title. #### UI or rather interaction steps On the [personal Snippets list view](https://gitlab.com/dashboard/snippets) next to `New snippet` button add new `Import from GitHub` button. On the click on `Import from GitHub` button show UI element (like modal) with text information like: "You can bulk import all your personal GitHub gists to your personal GitLab snippets, that are created independently of any project and listed here on the snippets dashboard. Your public gists will become snippets with public visibility level and your secret gists will become snippets with private visibility level. Note that only gists consisting of up to 10 files can be imported and any gists bigger than 10 files will be skipped." (Here link to documentation that says why we have this limit and encourages customers to manually migrate bigger than 10 files gists over to projects.) Under text buttons `Bulk-import gists` and `Cancel` After clicking on `Bulk-import gists` we have authentication (same as when importing projects from GitHub). After authentication a spinner `Importing...` (or whatever GitLab recommended simple solution is). In the later iteration we could maybe have an import progress bar. Finally imported gists are shown as snippets on the personal Snippets list. ### Iteration plan 1. :footprints: [GitHub Importer: API for bulk import of personal gists to personal snippets](https://gitlab.com/gitlab-org/gitlab/-/issues/371099) 1. :footprints: [GitHub importer: give feedback to the user on gists that were skipped as too big or didn't import because of other reasons](https://gitlab.com/gitlab-org/gitlab/-/issues/376283) 2. :footprints: [GitHub Importer: enable bulk import of personal gists to personal snippets in UI - BE](https://gitlab.com/gitlab-org/gitlab/-/issues/376278) 3. :footprints: [GitHub Importer: enable bulk import of personal gists to personal snippets in UI - FE](https://gitlab.com/gitlab-org/gitlab/-/issues/376284) #### Useful links GitHub gists: https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists Gists API: https://docs.github.com/en/rest/gists/gists GitLab snippets: https://docs.gitlab.com/ee/user/snippets.html#snippets Snippets API: https://docs.gitlab.com/ee/api/snippets.html ### Note There is a current limit of 10 files for GitLab Snippets. <!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION --> *This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.* <!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION -->
epic