Skip to content

Add self-hosted Gitlab migration support #9096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
4 changes: 4 additions & 0 deletions modules/migrations/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For self-hosted gitlab, we need a new option on the UI to let user select.

matched = true
}

return matched, nil
}
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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]);
}
});

Expand Down