Skip to content

Commit

Permalink
feat(taps): Add files and stats to PullRequestCommitsStream (#241)
Browse files Browse the repository at this point in the history
The purpose of this PR is to add the `files` and `stats` propertied to
the `PullRequestCommitsStream`.

These properties contain information about the changes done on a given
commit (`additions`, `deletions` and `total`). `files` has these
detailed at the file level whereas `stats` has a summary of changes at
the commit level.

---------

Co-authored-by: Dinis Louseiro <dimplouseiro@gmail>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 31, 2024
1 parent 054a21f commit 1608d52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tap_github/repository_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from tap_github.client import GitHubGraphqlStream, GitHubRestStream
from tap_github.schema_objects import (
files_object,
label_object,
milestone_object,
reactions_object,
Expand Down Expand Up @@ -1398,6 +1399,15 @@ class PullRequestCommits(GitHubRestStream):
)
),
),
th.Property("files", th.ArrayType(files_object)),
th.Property(
"stats",
th.ObjectType(
th.Property("additions", th.IntegerType),
th.Property("deletions", th.IntegerType),
th.Property("total", th.IntegerType),
),
),
).to_dict()

def post_process(self, row: dict, context: Optional[Dict[str, str]] = None) -> dict:
Expand Down
14 changes: 14 additions & 0 deletions tap_github/schema_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@
th.Property("rocket", th.IntegerType),
th.Property("eyes", th.IntegerType),
)

files_object = th.ObjectType(
th.Property("sha", th.StringType),
th.Property("filename", th.StringType),
th.Property("status", th.StringType),
th.Property("additions", th.IntegerType),
th.Property("deletions", th.IntegerType),
th.Property("changes", th.IntegerType),
th.Property("blob_url", th.StringType),
th.Property("raw_url", th.StringType),
th.Property("contents_url", th.StringType),
th.Property("patch", th.StringType),
th.Property("previous_filename", th.StringType),
)

0 comments on commit 1608d52

Please sign in to comment.