Skip to content

Commit

Permalink
✨ Authored and Commited dates to :octocat: commits (#4607)
Browse files Browse the repository at this point in the history
* ✨ Authored and Commited date to :octocat: commits

* fix: typo
--- commited
+++ committed
  • Loading branch information
slntopp authored Aug 26, 2024
1 parent ed46b81 commit d85d1c1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
4 changes: 4 additions & 0 deletions providers/github/resources/github.lr
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,10 @@ private github.commit @defaults("sha") {
commit git.commit
// Commit stats
stats dict
// Authored Date
authoredDate time
// Committed Date
committedDate time
}

// GitHub repository pull request
Expand Down
24 changes: 24 additions & 0 deletions providers/github/resources/github.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions providers/github/resources/github.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ resources:
github.commit:
fields:
author: {}
authoredDate:
min_mondoo_version: 9.0.0
commit:
min_mondoo_version: 6.11.0
commitedDate:
min_mondoo_version: 9.0.0
committedDate:
min_mondoo_version: 9.0.0
committer: {}
message: {}
organizationName: {}
Expand Down
20 changes: 11 additions & 9 deletions providers/github/resources/github_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func newMqlGithubCommit(runtime *plugin.Runtime, rc *github.RepositoryCommit, ow
conn := runtime.Connection.(*connection.GithubConnection)

// if the github author is nil, we have to load the commit again
if rc.Author == nil {
if rc.Author == nil || rc.Commit == nil {
rc, _, err = conn.Client().Repositories.GetCommit(conn.Context(), owner, repo, rc.GetSHA(), nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -685,14 +685,16 @@ func newMqlGithubCommit(runtime *plugin.Runtime, rc *github.RepositoryCommit, ow
}

return CreateResource(runtime, "github.commit", map[string]*llx.RawData{
"url": llx.StringData(rc.GetURL()),
"sha": llx.StringData(sha),
"author": llx.AnyData(githubAuthor),
"committer": llx.AnyData(githubCommitter),
"owner": llx.StringData(owner),
"repository": llx.StringData(repo),
"commit": llx.AnyData(mqlGitCommit),
"stats": llx.MapData(stats, types.Any),
"url": llx.StringData(rc.GetURL()),
"sha": llx.StringData(sha),
"author": llx.AnyData(githubAuthor),
"committer": llx.AnyData(githubCommitter),
"owner": llx.StringData(owner),
"repository": llx.StringData(repo),
"commit": llx.AnyData(mqlGitCommit),
"stats": llx.MapData(stats, types.Any),
"authoredDate": llx.TimeData(rc.Commit.Author.Date.Time),
"committedDate": llx.TimeData(rc.Commit.Committer.Date.Time),
})
}

Expand Down

0 comments on commit d85d1c1

Please sign in to comment.