Skip to content

Commit 526852f

Browse files
committed
improve code and token description
1 parent e048b88 commit 526852f

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

modules/migrations/github.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,23 @@ func NewGithubDownloaderV3(ctx context.Context, baseURL, userName, password, tok
109109
)
110110
client = oauth2.NewClient(downloader.ctx, ts)
111111

112-
githubClient := github.NewClient(client)
113-
if baseURL != "https://github.com" {
114-
githubClient, _ = github.NewEnterpriseClient(baseURL, baseURL, client)
115-
}
116-
downloader.clients = append(downloader.clients, githubClient)
117-
downloader.rates = append(downloader.rates, nil)
112+
downloader.addClient(client, baseURL)
118113
}
119114
} else {
120-
githubClient := github.NewClient(client)
121-
if baseURL != "https://github.com" {
122-
githubClient, _ = github.NewEnterpriseClient(baseURL, baseURL, client)
123-
}
124-
downloader.clients = append(downloader.clients, githubClient)
125-
downloader.rates = append(downloader.rates, nil)
115+
downloader.addClient(client, baseURL)
126116
}
127117
return &downloader
128118
}
129119

120+
func (g *GithubDownloaderV3) addClient(client *http.Client, baseURL string) {
121+
githubClient := github.NewClient(client)
122+
if baseURL != "https://github.com" {
123+
githubClient, _ = github.NewEnterpriseClient(baseURL, baseURL, client)
124+
}
125+
g.clients = append(g.clients, githubClient)
126+
g.rates = append(g.rates, nil)
127+
}
128+
130129
// SetContext set context
131130
func (g *GithubDownloaderV3) SetContext(ctx context.Context) {
132131
g.ctx = ctx

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ migrate_items_releases = Releases
887887
migrate_repo = Migrate Repository
888888
migrate.clone_address = Migrate / Clone From URL
889889
migrate.clone_address_desc = The HTTP(S) or Git 'clone' URL of an existing repository
890+
migrate.github_token_desc = You can put one or more tokens with comma separated here to make migrating faster because of Github API rate limit
890891
migrate.clone_local_path = or a local server path
891892
migrate.permission_denied = You are not allowed to import local repositories.
892893
migrate.permission_denied_blocked = You are not allowed to import from blocked hosts.

templates/repo/migrate/github.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
1515
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
1616
<span class="help">
17-
{{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}}
17+
{{.i18n.Tr "repo.migrate.clone_address_desc"}}
1818
</span>
1919
</div>
2020

2121
<div class="inline field {{if .Err_Auth}}error{{end}}">
2222
<label for="auth_token">{{.i18n.Tr "access_token"}}</label>
2323
<input id="auth_token" name="auth_token" value="{{.auth_token}}" {{if not .auth_token}}data-need-clear="true"{{end}}>
2424
<a target="_blank" href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">{{svg "octicon-question"}}</a>
25+
<span class="help">
26+
{{.i18n.Tr "repo.migrate.github_token_desc"}}
27+
</span>
2528
</div>
2629

2730
{{template "repo/migrate/options" .}}

0 commit comments

Comments
 (0)