diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go index 4f218c95f1f99..2d2047e00bb1f 100644 --- a/modules/migrations/gitlab.go +++ b/modules/migrations/gitlab.go @@ -33,6 +33,7 @@ type GitlabDownloaderFactory struct { } // Match returns true if the migration remote URL matched this downloader factory +// To allow self-hosting Gitlab instances, this matches based on the Host or a '#gitlab' fragment func (f *GitlabDownloaderFactory) Match(opts base.MigrateOptions) (bool, error) { var matched bool @@ -43,6 +44,9 @@ func (f *GitlabDownloaderFactory) Match(opts base.MigrateOptions) (bool, error) if strings.EqualFold(u.Host, "gitlab.com") && opts.AuthUsername != "" { matched = true } + if strings.EqualFold(u.Fragment, "gitlab") && opts.AuthUsername != "" { + matched = true + } return matched, nil } diff --git a/web_src/js/index.js b/web_src/js/index.js index a1b5035764e4a..931088248db83 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1160,7 +1160,7 @@ function initMigration() { const authUserName = $('#auth_username').val(); const cloneAddr = $('#clone_addr').val(); if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0) && - (cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com') || cloneAddr.startsWith('http://gitlab.com') || cloneAddr.startsWith('https://gitlab.com')))) { + (cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com') || cloneAddr.startsWith('http://gitlab.com') || cloneAddr.startsWith('https://gitlab.com') || cloneAddr.endsWith('#gitlab')))) { $('#migrate_items').show(); } else { $('#migrate_items').hide(); @@ -2481,7 +2481,7 @@ $(document).ready(async () => { $cloneAddr.on('change', () => { const $repoName = $('#repo_name'); if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank - $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); + $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?(#gitlab?))$/)[3]); } });