Skip to content

Commit

Permalink
feat: Add threshold.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jun 16, 2017
1 parent 9b1dcb5 commit 488d54a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 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(1 * time.Second).Format(GitHubSearchDateLayout)
datePreviousRef := commitPreviousRef.Commit.Committer.Date.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(1 * time.Second).Format(GitHubSearchDateLayout)
dateCurrentRef := commitCurrentRef.Commit.Committer.Date.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
16 changes: 9 additions & 7 deletions gcg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
func main() {

config := &types.Configuration{
BaseBranch: types.DefaultBaseBranch,
LabelEnhancement: types.DefaultEnhancementLabel,
LabelDocumentation: types.DefaultDocumentationLabel,
LabelBug: types.DefaultBugLabel,
OutputType: types.DefaultOutputDestination,
FileName: types.DefaultFileName,
DisplayLabel: true,
BaseBranch: types.DefaultBaseBranch,
LabelEnhancement: types.DefaultEnhancementLabel,
LabelDocumentation: types.DefaultDocumentationLabel,
LabelBug: types.DefaultBugLabel,
OutputType: types.DefaultOutputDestination,
FileName: types.DefaultFileName,
DisplayLabel: true,
ThresholdPreviousRef: 1,
ThresholdCurrentRef: 5,
}

defaultPointer := &types.Configuration{
Expand Down
2 changes: 2 additions & 0 deletions readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Flags:
-o, --owner Repository owner.
-p, --previous-ref Previous commit reference. Can be a tag, a branch, a SHA.
-r, --repo-name Repository name.
--th-after Threshold in seconds after the current ref date. (default "5")
--th-before Threshold in seconds after the previous ref date. (default "1")
-t, --token GitHub Token.
-h, --help Print Help (this message) and exit
----
Expand Down
2 changes: 2 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type Configuration struct {
OutputType string `long:"output-type" description:"Output destination type. (file|Stdout)"`
FileName string `long:"file-name" description:"Name of the changelog file."`
Debug bool `long:"debug" description:"Debug mode."`
ThresholdPreviousRef int `long:"th-before" description:"Threshold in seconds after the previous ref date."`
ThresholdCurrentRef int `long:"th-after" description:"Threshold in seconds after the current ref date."`
}

type DisplayLabelOptions struct {
Expand Down

0 comments on commit 488d54a

Please sign in to comment.