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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion github/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Commit struct {
Message string
Parents []Commit
StatusSuccess bool
PushedDate time.Time
AuthoredDate time.Time
AuthorName string
SpecificCheckPassed bool
}
3 changes: 2 additions & 1 deletion github/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}

Expand Down
8 changes: 7 additions & 1 deletion github/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manager/flow-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

Expand Down
Loading