fix: funlen

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2023-02-27 16:18:51 -06:00
parent 383ca9cd30
commit 85b044ae07
No known key found for this signature in database
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 14 additions and 20 deletions

View File

@ -28,16 +28,7 @@ type GitHub struct {
func (gh *GitHub) Generate() (string, []Entry, error) {
tagURL := fmt.Sprintf("## [%s](https://github.com/%s/releases/tag/%s) - %s", gh.Milestone, gh.Repo, gh.GitTag, time.Now().Format("2006-01-02"))
cl := http.DefaultClient
if token, ok := os.LookupEnv("CHANGELOG_GITHUB_TOKEN"); ok {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
cl = oauth2.NewClient(ctx, ts)
}
client := github.NewClient(cl)
client := github.NewClient(httpClient())
ctx := context.Background()
prs := make([]Entry, 0)
@ -93,16 +84,7 @@ func (gh *GitHub) Generate() (string, []Entry, error) {
// Contributors returns a list of contributors from GitHub
func (gh *GitHub) Contributors() (ContributorList, error) {
cl := http.DefaultClient
if token, ok := os.LookupEnv("CHANGELOG_GITHUB_TOKEN"); ok {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
cl = oauth2.NewClient(ctx, ts)
}
client := github.NewClient(cl)
client := github.NewClient(httpClient())
ctx := context.Background()
contributorsMap := make(map[string]bool)
@ -140,3 +122,15 @@ func (gh *GitHub) Contributors() (ContributorList, error) {
return contributors, nil
}
func httpClient() *http.Client {
cl := http.DefaultClient
if token, ok := os.LookupEnv("CHANGELOG_GITHUB_TOKEN"); ok {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
cl = oauth2.NewClient(ctx, ts)
}
return cl
}