Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions chronicle/release/summarizer/github/gh_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ issueLoop:
return results
}

func issuesAfter(since time.Time) issueFilter {
func issuesAtOrAfter(since time.Time) issueFilter {
return func(issue ghIssue) bool {
keep := issue.ClosedAt.After(since)
keep := issue.ClosedAt.After(since) || issue.ClosedAt.Equal(since)
if !keep {
log.Tracef("issue #%d filtered out: merged before %s", issue.Number, internal.FormatDateTime(since))
log.Tracef("issue #%d filtered out: closed before %s (closed %s)", issue.Number, internal.FormatDateTime(since), internal.FormatDateTime(issue.ClosedAt))
}
return keep
}
}

func issuesBefore(since time.Time) issueFilter {
func issuesAtOrBefore(since time.Time) issueFilter {
return func(issue ghIssue) bool {
keep := issue.ClosedAt.Before(since)
keep := issue.ClosedAt.Before(since) || issue.ClosedAt.Equal(since)
if !keep {
log.Tracef("issue #%d filtered out: merged after %s", issue.Number, internal.FormatDateTime(since))
log.Tracef("issue #%d filtered out: closed after %s (closed %s)", issue.Number, internal.FormatDateTime(since), internal.FormatDateTime(issue.ClosedAt))
}
return keep
}
Expand Down
20 changes: 18 additions & 2 deletions chronicle/release/summarizer/github/gh_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ func Test_issuesAfter(t *testing.T) {
},
expected: false,
},
{
name: "pr is equal to compare date",
since: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
issue: ghIssue{
ClosedAt: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
},
expected: true,
},
{
name: "pr is after compare date",
since: time.Date(2021, time.September, 16, 19, 34, 0, 0, time.UTC),
Expand All @@ -34,7 +42,7 @@ func Test_issuesAfter(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expected, issuesAfter(test.since)(test.issue))
assert.Equal(t, test.expected, issuesAtOrAfter(test.since)(test.issue))
})
}
}
Expand All @@ -55,6 +63,14 @@ func Test_issuesBefore(t *testing.T) {
},
expected: false,
},
{
name: "pr is equal to compare date",
until: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
issue: ghIssue{
ClosedAt: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
},
expected: true,
},
{
name: "pr is before compare date",
until: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
Expand All @@ -66,7 +82,7 @@ func Test_issuesBefore(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expected, issuesBefore(test.until)(test.issue))
assert.Equal(t, test.expected, issuesAtOrBefore(test.until)(test.issue))
})
}
}
Expand Down
14 changes: 8 additions & 6 deletions chronicle/release/summarizer/github/gh_pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"time"

"github.com/anchore/chronicle/internal"

"github.com/anchore/chronicle/internal/log"

"github.com/shurcooL/githubv4"
Expand Down Expand Up @@ -43,21 +45,21 @@ prLoop:
return results
}

func prsAfter(since time.Time) prFilter {
func prsAtOrAfter(since time.Time) prFilter {
return func(pr ghPullRequest) bool {
keep := pr.MergedAt.After(since)
keep := pr.MergedAt.After(since) || pr.MergedAt.Equal(since)
if !keep {
log.Tracef("PR #%d filtered out: merged before %s", pr.Number, since.Format("2006-01-02 15:04"))
log.Tracef("PR #%d filtered out: merged before %s (merged %s)", pr.Number, internal.FormatDateTime(since), internal.FormatDateTime(pr.MergedAt))
}
return keep
}
}

func prsBefore(since time.Time) prFilter {
func prsAtOrBefore(since time.Time) prFilter {
return func(pr ghPullRequest) bool {
keep := pr.MergedAt.Before(since)
keep := pr.MergedAt.Before(since) || pr.MergedAt.Equal(since)
if !keep {
log.Tracef("PR #%d filtered out: merged after %s", pr.Number, since.Format("2006-01-02 15:04"))
log.Tracef("PR #%d filtered out: merged after %s (merged %s)", pr.Number, internal.FormatDateTime(since), internal.FormatDateTime(pr.MergedAt))
}
return keep
}
Expand Down
20 changes: 18 additions & 2 deletions chronicle/release/summarizer/github/gh_pull_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ func Test_prsAfter(t *testing.T) {
},
expected: false,
},
{
name: "pr is equal to compare date",
since: time.Date(2021, time.September, 16, 19, 34, 0, 0, time.UTC),
pr: ghPullRequest{
MergedAt: time.Date(2021, time.September, 16, 19, 34, 0, 0, time.UTC),
},
expected: true,
},
{
name: "pr is after compare date",
since: time.Date(2021, time.September, 16, 19, 34, 0, 0, time.UTC),
Expand All @@ -34,7 +42,7 @@ func Test_prsAfter(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expected, prsAfter(test.since)(test.pr))
assert.Equal(t, test.expected, prsAtOrAfter(test.since)(test.pr))
})
}
}
Expand All @@ -55,6 +63,14 @@ func Test_prsBefore(t *testing.T) {
},
expected: false,
},
{
name: "pr is equal to compare date",
until: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
pr: ghPullRequest{
MergedAt: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
},
expected: true,
},
{
name: "pr is before compare date",
until: time.Date(2021, time.September, 18, 19, 34, 0, 0, time.UTC),
Expand All @@ -66,7 +82,7 @@ func Test_prsBefore(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expected, prsBefore(test.until)(test.pr))
assert.Equal(t, test.expected, prsAtOrBefore(test.until)(test.pr))
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions chronicle/release/summarizer/github/summarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (s *Summarizer) changesFromPRs(sinceRef, untilRef string) ([]change.Change,
}

filters := []prFilter{
prsAfter(sinceTag.Timestamp),
prsAtOrAfter(sinceTag.Timestamp.UTC()),
prsWithLabel(s.config.ChangeTypesByLabel.Names()...),
prsWithoutLabel(s.config.ExcludeLabels...),
// Merged PRs linked to closed issues should be hidden so that the closed pr summary takes precedence
Expand All @@ -136,7 +136,7 @@ func (s *Summarizer) changesFromPRs(sinceRef, untilRef string) ([]change.Change,
return nil, err
}

filters = append(filters, prsBefore(untilTag.Timestamp))
filters = append(filters, prsAtOrBefore(untilTag.Timestamp.UTC()))
}

filteredPRs := filterPRs(allMergedPRs, filters...)
Expand Down Expand Up @@ -183,7 +183,7 @@ func (s *Summarizer) changesFromIssues(sinceRef, untilRef string) ([]change.Chan
}

filters := []issueFilter{
issuesAfter(sinceTag.Timestamp),
issuesAtOrAfter(sinceTag.Timestamp),
issuesWithLabel(s.config.ChangeTypesByLabel.Names()...),
issuesWithoutLabel(s.config.ExcludeLabels...),
}
Expand All @@ -194,7 +194,7 @@ func (s *Summarizer) changesFromIssues(sinceRef, untilRef string) ([]change.Chan
return nil, err
}

filters = append(filters, issuesBefore(untilTag.Timestamp))
filters = append(filters, issuesAtOrBefore(untilTag.Timestamp))
}

filteredIssues := filterIssues(allClosedIssues, filters...)
Expand Down
2 changes: 1 addition & 1 deletion internal/time_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package internal
import "time"

func FormatDateTime(t time.Time) string {
return t.Format("YYYY-MM-DD 15:04")
return t.UTC().Format("2006-01-02 15:04 MST")
}