From 21b778301ccd7cbbf64fa40d56a89f9d1cae12bf Mon Sep 17 00:00:00 2001 From: Jordan Anderson Date: Wed, 20 Nov 2019 10:30:28 -0600 Subject: [PATCH 1/3] Add support for self-hosted Gitlab instances. Just add a '#gitlab' fragment to the end of your Clone Address. --- modules/migrations/gitlab.go | 4 ++++ web_src/js/index.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go index 02891d504d65a..ecc0882051dca 100644 --- a/modules/migrations/gitlab.go +++ b/modules/migrations/gitlab.go @@ -33,6 +33,7 @@ type GitlabDownloaderFactory struct { } // Match returns ture 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 2bf34a956df08..fa6f475ccbacc 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1162,7 +1162,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(); @@ -2632,7 +2632,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]); } }); From 98276679e83afc29fdd2cabb704311f564feaf99 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Apr 2020 22:52:40 +0200 Subject: [PATCH 2/3] always use baseURL --- modules/migrations/gitlab.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go index ecc0882051dca..c217e64c63032 100644 --- a/modules/migrations/gitlab.go +++ b/modules/migrations/gitlab.go @@ -94,7 +94,7 @@ func NewGitlabDownloader(baseURL, repoPath, username, password string) *GitlabDo var err error if username != "" { if password == "" { - gitlabClient, err = gitlab.NewClient(username) + gitlabClient, err = gitlab.NewClient(username, gitlab.WithBaseURL(baseURL)) } else { gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL)) } From 8a450dfda882640c0f2e00bc5268b476f0ead721 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 20 Apr 2020 01:04:13 +0200 Subject: [PATCH 3/3] rm space on comment --- modules/migrations/gitlab.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go index c217e64c63032..d4f5159bf88ad 100644 --- a/modules/migrations/gitlab.go +++ b/modules/migrations/gitlab.go @@ -33,7 +33,7 @@ type GitlabDownloaderFactory struct { } // Match returns ture 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 +// 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