Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion 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 Expand Up @@ -90,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))
}
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 @@ -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();
Expand Down Expand Up @@ -2623,7 +2623,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