diff --git a/README.md b/README.md index f33537a..514ee88 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ - [Commit message not contains "string"](#commit-message-not-contains-string) - [Commit message equals "string"](#commit-message-equals-string) - [Commit status is SUCCESS](#commit-status-is-success) - - [Commit was pushed more than 30 minutes ago](#commit-was-pushed-more-than-30-minutes-ago) - - [Commit was pushed more than 30 minutes ago and status is SUCCESS](#commit-was-pushed-more-than-30-minutes-ago-and-status-is-success) + - [Commit was authored more than 30 minutes ago](#commit-was-authored-more-than-30-minutes-ago) + - [Commit was authored more than 30 minutes ago and status is SUCCESS](#commit-was-authored-more-than-30-minutes-ago-and-status-is-success) - [How to build](#how-to-build) @@ -76,7 +76,7 @@ This repo leverage pre commit to lint, secure, document the IaaC codebase. The p - `SHA` - `Message` -- `PushedDate` - when commit was pushed +- `AuthoredDate` - when commit was authored - `StatusSuccess` - f.ex. CI status ## Examples @@ -97,13 +97,13 @@ This repo leverage pre commit to lint, secure, document the IaaC codebase. The p `StatusSuccess == true` -### Commit was pushed more than 30 minutes ago +### Commit was authored more than 30 minutes ago -`PushedDate < "now-30m"` +`AuthoredDate < "now-30m"` -### Commit was pushed more than 30 minutes ago and status is SUCCESS +### Commit was authored more than 30 minutes ago and status is SUCCESS -`PushedDate < "now-30m" AND StatusSuccess == true` +`AuthoredDate < "now-30m" AND StatusSuccess == true` ## How to build diff --git a/cmd/root.go b/cmd/root.go index 0217257..6bbbf72 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -85,7 +85,7 @@ If a SPECIFIC_COMMIT_CHECK_NAME is specified, the StatusSuccess will be calculat table := tablewriter.NewWriter(os.Stdout) table.SetRowLine(true) - table.SetHeader([]string{"SHA", "MESSAGE", "PUSHED_AT", "IS_STATUS_SUCCESS", "EVALUATION"}) + table.SetHeader([]string{"SHA", "MESSAGE", "AUTHORED_AT", "AUTHORED_BY", "IS_STATUS_SUCCESS", "EVALUATION"}) for _, res := range results { c := res.Commit @@ -100,7 +100,7 @@ If a SPECIFIC_COMMIT_CHECK_NAME is specified, the StatusSuccess will be calculat resultSign = symbolSuccess } - table.Append([]string{c.SHA, c.Message, c.PushedDate.Format(time.RFC3339), statusSign, resultSign}) + table.Append([]string{c.SHA, c.Message, c.AuthoredDate.Format(time.RFC3339), c.AuthorName, statusSign, resultSign}) } table.Render() diff --git a/github/commit.go b/github/commit.go index 9ec0a72..2ac7590 100644 --- a/github/commit.go +++ b/github/commit.go @@ -8,6 +8,7 @@ type Commit struct { Message string Parents []Commit StatusSuccess bool - PushedDate time.Time + AuthoredDate time.Time + AuthorName string SpecificCheckPassed bool } diff --git a/github/manager.go b/github/manager.go index c24452b..03dc457 100644 --- a/github/manager.go +++ b/github/manager.go @@ -166,7 +166,8 @@ func hydrateCommits(q *Query, specificChecksNames string, sep string) []Commit { Message: string(edge.Node.Message), Parents: parents, StatusSuccess: statusSuccess, - PushedDate: edge.Node.PushedDate.Time, + AuthoredDate: edge.Node.AuthoredDate.Time, + AuthorName: string(edge.Node.Author.Name), }) } diff --git a/github/types.go b/github/types.go index 7336bc5..bd70c52 100644 --- a/github/types.go +++ b/github/types.go @@ -75,6 +75,11 @@ type StatusCheckRollup struct { Contexts StatusCheckRollupContexts `graphql:"contexts(first: $parentsNumber)"` } +// Author represents the information about the commit author +type Author struct { + Name githubv4.String +} + // ParentsEdge represents the information about the parents edge type ParentsEdge struct { Edges []EdgeParent @@ -85,7 +90,8 @@ type EdgeRootNode struct { Parents ParentsEdge `graphql:"parents(first: $parentsNumber)"` Oid githubv4.String Message githubv4.String - PushedDate githubv4.DateTime + AuthoredDate githubv4.DateTime + Author Author StatusCheckRollup StatusCheckRollup CheckSuites CheckSuites `graphql:"checkSuites(first: 20)"` Status NodeStatus diff --git a/manager/flow-manager.go b/manager/flow-manager.go index ebea162..7c55447 100644 --- a/manager/flow-manager.go +++ b/manager/flow-manager.go @@ -48,7 +48,7 @@ func Manage(githubToken, owner, repo, sourceBranch, destinationBranch, expressio evalContext := datasource.NewContextSimpleNative(map[string]interface{}{ "SHA": commit.SHA, "Message": commit.Message, - "PushedDate": commit.PushedDate, + "AuthoredDate": commit.AuthoredDate, "StatusSuccess": commit.StatusSuccess, })