From 1608d52a6d942c70039e037154814fab584195d3 Mon Sep 17 00:00:00 2001 From: Dinis Louseiro Date: Thu, 1 Feb 2024 00:06:16 +0100 Subject: [PATCH] feat(taps): Add `files` and `stats` to `PullRequestCommitsStream` (#241) 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 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- tap_github/repository_streams.py | 10 ++++++++++ tap_github/schema_objects.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tap_github/repository_streams.py b/tap_github/repository_streams.py index d70889b6..16104839 100644 --- a/tap_github/repository_streams.py +++ b/tap_github/repository_streams.py @@ -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, @@ -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: diff --git a/tap_github/schema_objects.py b/tap_github/schema_objects.py index 7a74ed2c..98381f16 100644 --- a/tap_github/schema_objects.py +++ b/tap_github/schema_objects.py @@ -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), +)