Skip to content

Commit 3ec5aed

Browse files
Merge pull request #32 from DocPlanner/fix/pushed-date-deprecated
fix: replace deprecated PushedDate by AuthoredDate, add Author to the result
2 parents 6752dd6 + 6c6065b commit 3ec5aed

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
- [Commit message not contains "string"](#commit-message-not-contains-string)
1919
- [Commit message equals "string"](#commit-message-equals-string)
2020
- [Commit status is SUCCESS](#commit-status-is-success)
21-
- [Commit was pushed more than 30 minutes ago](#commit-was-pushed-more-than-30-minutes-ago)
22-
- [Commit was pushed more than 30 minutes ago and status is SUCCESS](#commit-was-pushed-more-than-30-minutes-ago-and-status-is-success)
21+
- [Commit was authored more than 30 minutes ago](#commit-was-authored-more-than-30-minutes-ago)
22+
- [Commit was authored more than 30 minutes ago and status is SUCCESS](#commit-was-authored-more-than-30-minutes-ago-and-status-is-success)
2323
- [How to build](#how-to-build)
2424

2525
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -76,7 +76,7 @@ This repo leverage pre commit to lint, secure, document the IaaC codebase. The p
7676
7777
- `SHA`
7878
- `Message`
79-
- `PushedDate` - when commit was pushed
79+
- `AuthoredDate` - when commit was authored
8080
- `StatusSuccess` - f.ex. CI status
8181
8282
## Examples
@@ -97,13 +97,13 @@ This repo leverage pre commit to lint, secure, document the IaaC codebase. The p
9797
9898
`StatusSuccess == true`
9999
100-
### Commit was pushed more than 30 minutes ago
100+
### Commit was authored more than 30 minutes ago
101101
102-
`PushedDate < "now-30m"`
102+
`AuthoredDate < "now-30m"`
103103
104-
### Commit was pushed more than 30 minutes ago and status is SUCCESS
104+
### Commit was authored more than 30 minutes ago and status is SUCCESS
105105
106-
`PushedDate < "now-30m" AND StatusSuccess == true`
106+
`AuthoredDate < "now-30m" AND StatusSuccess == true`
107107
108108
## How to build
109109

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ If a SPECIFIC_COMMIT_CHECK_NAME is specified, the StatusSuccess will be calculat
8585

8686
table := tablewriter.NewWriter(os.Stdout)
8787
table.SetRowLine(true)
88-
table.SetHeader([]string{"SHA", "MESSAGE", "PUSHED_AT", "IS_STATUS_SUCCESS", "EVALUATION"})
88+
table.SetHeader([]string{"SHA", "MESSAGE", "AUTHORED_AT", "AUTHORED_BY", "IS_STATUS_SUCCESS", "EVALUATION"})
8989

9090
for _, res := range results {
9191
c := res.Commit
@@ -100,7 +100,7 @@ If a SPECIFIC_COMMIT_CHECK_NAME is specified, the StatusSuccess will be calculat
100100
resultSign = symbolSuccess
101101
}
102102

103-
table.Append([]string{c.SHA, c.Message, c.PushedDate.Format(time.RFC3339), statusSign, resultSign})
103+
table.Append([]string{c.SHA, c.Message, c.AuthoredDate.Format(time.RFC3339), c.AuthorName, statusSign, resultSign})
104104
}
105105

106106
table.Render()

github/commit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Commit struct {
88
Message string
99
Parents []Commit
1010
StatusSuccess bool
11-
PushedDate time.Time
11+
AuthoredDate time.Time
12+
AuthorName string
1213
SpecificCheckPassed bool
1314
}

github/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ func hydrateCommits(q *Query, specificChecksNames string, sep string) []Commit {
166166
Message: string(edge.Node.Message),
167167
Parents: parents,
168168
StatusSuccess: statusSuccess,
169-
PushedDate: edge.Node.PushedDate.Time,
169+
AuthoredDate: edge.Node.AuthoredDate.Time,
170+
AuthorName: string(edge.Node.Author.Name),
170171
})
171172
}
172173

github/types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ type StatusCheckRollup struct {
7575
Contexts StatusCheckRollupContexts `graphql:"contexts(first: $parentsNumber)"`
7676
}
7777

78+
// Author represents the information about the commit author
79+
type Author struct {
80+
Name githubv4.String
81+
}
82+
7883
// ParentsEdge represents the information about the parents edge
7984
type ParentsEdge struct {
8085
Edges []EdgeParent
@@ -85,7 +90,8 @@ type EdgeRootNode struct {
8590
Parents ParentsEdge `graphql:"parents(first: $parentsNumber)"`
8691
Oid githubv4.String
8792
Message githubv4.String
88-
PushedDate githubv4.DateTime
93+
AuthoredDate githubv4.DateTime
94+
Author Author
8995
StatusCheckRollup StatusCheckRollup
9096
CheckSuites CheckSuites `graphql:"checkSuites(first: 20)"`
9197
Status NodeStatus

manager/flow-manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func Manage(githubToken, owner, repo, sourceBranch, destinationBranch, expressio
4848
evalContext := datasource.NewContextSimpleNative(map[string]interface{}{
4949
"SHA": commit.SHA,
5050
"Message": commit.Message,
51-
"PushedDate": commit.PushedDate,
51+
"AuthoredDate": commit.AuthoredDate,
5252
"StatusSuccess": commit.StatusSuccess,
5353
})
5454

0 commit comments

Comments
 (0)