Skip to content

Commit

Permalink
refactor: better use og Github lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jul 29, 2017
1 parent 488d54a commit bc3e74a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 deletions core/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func Generate(config *types.Configuration) {
commitPreviousRef, _, err := client.Repositories.GetCommit(ctx, config.Owner, config.RepositoryName, config.PreviousRef)
check(err)

datePreviousRef := commitPreviousRef.Commit.Committer.Date.Add(time.Duration(config.ThresholdPreviousRef) * time.Second).Format(GitHubSearchDateLayout)
datePreviousRef := commitPreviousRef.Commit.Committer.GetDate().Add(time.Duration(config.ThresholdPreviousRef) * time.Second).Format(GitHubSearchDateLayout)

// Get current ref version date
commitCurrentRef, _, err := client.Repositories.GetCommit(ctx, config.Owner, config.RepositoryName, config.CurrentRef)
check(err)

dateCurrentRef := commitCurrentRef.Commit.Committer.Date.Add(time.Duration(config.ThresholdCurrentRef) * time.Second).Format(GitHubSearchDateLayout)
dateCurrentRef := commitCurrentRef.Commit.Committer.GetDate().Add(time.Duration(config.ThresholdCurrentRef) * time.Second).Format(GitHubSearchDateLayout)

// Search PR
query := fmt.Sprintf("type:pr is:merged repo:%s/%s base:%s merged:%s..%s",
Expand Down Expand Up @@ -94,7 +94,7 @@ func searchAllIssues(ctx context.Context, client *github.Client, query string, s
for _, issue := range issuesSearchResult.Issues {
if containsLeastOne(issue.Labels, config.LabelExcludes) {
if config.Debug {
log.Println("Exclude:", *issue.Number, *issue.Title)
log.Println("Exclude:", issue.GetNumber(), issue.GetTitle())
}
} else {
allIssues = append(allIssues, issue)
Expand Down Expand Up @@ -130,7 +130,7 @@ func display(config *types.Configuration, issues []github.Issue, commitCurrentRe
sort.Sort(types.ByLabel(summary.Bug))
sort.Sort(types.ByLabel(summary.Other))

summary.CurrentRefDate = commitCurrentRef.Commit.Committer.Date.Format("2006-01-02")
summary.CurrentRefDate = commitCurrentRef.Commit.Committer.GetDate().Format("2006-01-02")
if len(config.FutureCurrentRefName) == 0 {
summary.CurrentRefName = config.CurrentRef
} else {
Expand Down Expand Up @@ -182,7 +182,7 @@ func contains(labels []github.Label, str string) bool {

func containsLeastOne(labels []github.Label, values []string) bool {
for _, lbl := range labels {
if isIn(*lbl.Name, values) {
if isIn(lbl.GetName(), values) {
return true
}
}
Expand Down
11 changes: 5 additions & 6 deletions types/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package types

import (
"errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -72,13 +71,13 @@ func (c *LabelDisplayOptionsParser) SetValue(val interface{}) {

type SliceString []string

func (c *SliceString) Set(value string) error {
values := strings.Split(value, ",")
func (c *SliceString) Set(rawValue string) error {
values := strings.Split(rawValue, ",")
if len(values) == 0 {
return errors.New("Bad Value format: " + value)
return fmt.Errorf("Bad Value format: %s", rawValue)
}
for _, val := range values {
*c = append(*c, val)
for _, value := range values {
*c = append(*c, value)
}
return nil
}
Expand Down

0 comments on commit bc3e74a

Please sign in to comment.