Skip to content

Commit ef8d489

Browse files
authored
add comparecommits and getcommits to gh sdk (#1167)
xref: chainguard-dev/internal-dev#21193
1 parent bb4b566 commit ef8d489

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

modules/github-bots/sdk/github.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,27 @@ func (c GitHubClient) ListFiles(ctx context.Context, owner, repo, path, ref stri
737737

738738
return dirContents, nil
739739
}
740+
741+
// CompareCommits fetches the differences between two commits
742+
func (c GitHubClient) CompareCommits(ctx context.Context, owner, repo, base, head string, opts *github.ListOptions) (*github.CommitsComparison, error) {
743+
comparison, resp, err := c.inner.Repositories.CompareCommits(
744+
ctx, owner, repo, base, head, opts,
745+
)
746+
if err := validateResponse(ctx, err, resp, fmt.Sprintf("compare commits %s...%s", base, head)); err != nil {
747+
return nil, err
748+
}
749+
750+
return comparison, nil
751+
}
752+
753+
// GetCommitDetails fetches the details of a single commit
754+
func (c GitHubClient) GetCommitDetails(ctx context.Context, owner, repo, sha string, opts *github.ListOptions) (*github.RepositoryCommit, error) {
755+
cDetails, resp, err := c.inner.Repositories.GetCommit(
756+
ctx, owner, repo, sha, opts,
757+
)
758+
if err := validateResponse(ctx, err, resp, fmt.Sprintf("get commit details for %s", sha)); err != nil {
759+
return nil, err
760+
}
761+
762+
return cDetails, nil
763+
}

0 commit comments

Comments
 (0)