Skip to content

Commit 21b7783

Browse files
aqtrans6543
authored andcommitted
Add support for self-hosted Gitlab instances.
Just add a '#gitlab' fragment to the end of your Clone Address.
1 parent 77fecec commit 21b7783

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

modules/migrations/gitlab.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type GitlabDownloaderFactory struct {
3333
}
3434

3535
// Match returns ture if the migration remote URL matched this downloader factory
36+
// To allow self-hosting Gitlab instances, this matches based on the Host or a '#gitlab' fragment
3637
func (f *GitlabDownloaderFactory) Match(opts base.MigrateOptions) (bool, error) {
3738
var matched bool
3839

@@ -43,6 +44,9 @@ func (f *GitlabDownloaderFactory) Match(opts base.MigrateOptions) (bool, error)
4344
if strings.EqualFold(u.Host, "gitlab.com") && opts.AuthUsername != "" {
4445
matched = true
4546
}
47+
if strings.EqualFold(u.Fragment, "gitlab") && opts.AuthUsername != "" {
48+
matched = true
49+
}
4650

4751
return matched, nil
4852
}

web_src/js/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ function initMigration() {
11621162
const authUserName = $('#auth_username').val();
11631163
const cloneAddr = $('#clone_addr').val();
11641164
if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0) &&
1165-
(cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com') || cloneAddr.startsWith('http://gitlab.com') || cloneAddr.startsWith('https://gitlab.com')))) {
1165+
(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')))) {
11661166
$('#migrate_items').show();
11671167
} else {
11681168
$('#migrate_items').hide();
@@ -2632,7 +2632,7 @@ $(document).ready(async () => {
26322632
$cloneAddr.on('change', () => {
26332633
const $repoName = $('#repo_name');
26342634
if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank
2635-
$repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]);
2635+
$repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?(#gitlab?))$/)[3]);
26362636
}
26372637
});
26382638

0 commit comments

Comments
 (0)