mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
fixes
This commit is contained in:
parent
df97d6c2d3
commit
337eb607fc
@ -23,10 +23,15 @@ All open pull requests created by you.
|
||||
wtf/github/
|
||||
```
|
||||
|
||||
## Required ENV Variables
|
||||
## Github Required ENV Variables
|
||||
|
||||
<span class="caption">Key:</span> `WTF_GITHUB_TOKEN` <br />
|
||||
<span class="caption">Action:</span> Your <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">Github API</a> token or <a href="https://developer.github.com/enterprise/2.13/v3/enterprise-admin/">Github Enterprise</a> API token.
|
||||
<span class="caption">Action:</span> Your <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">Github API</a> token.
|
||||
|
||||
## GitHub Enterprise Required ENV Variables
|
||||
|
||||
<span class="caption">Key:</span> `WTF_GITHUB_TOKEN` <br />
|
||||
<span class="caption">Action:</span> Your <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">Github API</a> token.
|
||||
|
||||
<span class="caption">Key:</span> `WTF_GITHUB_BASE_URL` <br />
|
||||
<span class="caption">Action:</span> Your <a href="https://developer.github.com/enterprise/2.13/v3/enterprise-admin/">Github Enterprise</a> API URL.
|
||||
|
@ -63,6 +63,16 @@ func (repo *GithubRepo) StarCount() int {
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (repo *GithubRepo) isGitHubEnterprise() bool {
|
||||
if len(repo.baseURL) > 0 {
|
||||
if len(repo.uploadURL) == 0 {
|
||||
repo.uploadURL = repo.baseURL
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (repo *GithubRepo) oauthClient() *http.Client {
|
||||
tokenService := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: repo.apiKey},
|
||||
@ -74,11 +84,8 @@ func (repo *GithubRepo) oauthClient() *http.Client {
|
||||
func (repo *GithubRepo) githubClient() (*ghb.Client, error) {
|
||||
oauthClient := repo.oauthClient()
|
||||
|
||||
if len(repo.baseURL) > 0 {
|
||||
if len(repo.uploadURL) == 0 {
|
||||
repo.uploadURL = repo.baseURL
|
||||
}
|
||||
return ghb.NewEnterpriseClient(repo.baseURL, repo.baseURL, oauthClient)
|
||||
if repo.isGitHubEnterprise() {
|
||||
return ghb.NewEnterpriseClient(repo.baseURL, repo.uploadURL, oauthClient)
|
||||
}
|
||||
|
||||
return ghb.NewClient(oauthClient), nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user