@@ -47,13 +47,14 @@ func (f *GithubDownloaderV3Factory) New(ctx context.Context, opts base.MigrateOp
47
47
return nil , err
48
48
}
49
49
50
+ baseURL := u .Scheme + "://" + u .Host
50
51
fields := strings .Split (u .Path , "/" )
51
52
oldOwner := fields [1 ]
52
53
oldName := strings .TrimSuffix (fields [2 ], ".git" )
53
54
54
55
log .Trace ("Create github downloader: %s/%s" , oldOwner , oldName )
55
56
56
- return NewGithubDownloaderV3 (ctx , opts .AuthUsername , opts .AuthPassword , opts .AuthToken , oldOwner , oldName ), nil
57
+ return NewGithubDownloaderV3 (ctx , baseURL , opts .AuthUsername , opts .AuthPassword , opts .AuthToken , oldOwner , oldName ), nil
57
58
}
58
59
59
60
// GitServiceType returns the type of git service
@@ -74,7 +75,7 @@ type GithubDownloaderV3 struct {
74
75
}
75
76
76
77
// NewGithubDownloaderV3 creates a github Downloader via github v3 API
77
- func NewGithubDownloaderV3 (ctx context.Context , userName , password , token , repoOwner , repoName string ) * GithubDownloaderV3 {
78
+ func NewGithubDownloaderV3 (ctx context.Context , baseURL , userName , password , token , repoOwner , repoName string ) * GithubDownloaderV3 {
78
79
var downloader = GithubDownloaderV3 {
79
80
userName : userName ,
80
81
password : password ,
@@ -98,6 +99,9 @@ func NewGithubDownloaderV3(ctx context.Context, userName, password, token, repoO
98
99
client = oauth2 .NewClient (downloader .ctx , ts )
99
100
}
100
101
downloader .client = github .NewClient (client )
102
+ if baseURL != "https://github.com" {
103
+ downloader .client , _ = github .NewEnterpriseClient (baseURL , baseURL , client )
104
+ }
101
105
return & downloader
102
106
}
103
107
0 commit comments