Skip to content

Conversation

@Meldiron
Copy link
Contributor

@Meldiron Meldiron commented Dec 16, 2025

Summary by CodeRabbit

  • New Features

    • Push webhook events now include an affectedFiles list that aggregates all files added, removed, or modified across commits in a push.
  • Tests

    • Updated push event tests to validate the affectedFiles contents and ordering across commits.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The GitHub webhook push-event handling in GitHub::getEvent now aggregates an affectedFiles array by iterating all commits and collecting added, removed, and modified filenames, deduplicating entries. The affectedFiles list is included in the array returned for the push event. Tests were updated to include a commit with added, removed, and modified entries and to assert the affectedFiles contents and ordering (src/lib.js, README.md, src/main.js).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify deduplication across multiple commits in a single push.
  • Confirm affectedFiles is present and correctly formatted in the push branch of the returned payload.
  • Review updated test assertions for expected order and content.
  • Check edge cases: overlapping file lists, empty commits, and large commit arrays.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat: Affected files' directly corresponds to the main change: adding an 'affectedFiles' field to the GitHub webhook push event payload.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-event-affected-files

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/VCS/Adapter/GitHubTest.php (1)

150-153: Consider order-independent assertions for robustness.

The test assertions validate both the count and specific order of affected files. While the current implementation maintains insertion order, this creates a dependency on the order of commits in the webhook payload.

For more robust testing, consider verifying the presence of files without assuming order:

         $this->assertCount(3, $pushResult['affectedFiles']);
-        $this->assertSame('src/lib.js', $pushResult['affectedFiles'][0]);
-        $this->assertSame('README.md', $pushResult['affectedFiles'][1]);
-        $this->assertSame('src/main.js', $pushResult['affectedFiles'][2]);
+        $this->assertContains('src/lib.js', $pushResult['affectedFiles']);
+        $this->assertContains('README.md', $pushResult['affectedFiles']);
+        $this->assertContains('src/main.js', $pushResult['affectedFiles']);

Alternatively, if order is intentional and important, document this behavior explicitly.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c59e21d and de2c367.

📒 Files selected for processing (2)
  • src/VCS/Adapter/Git/GitHub.php (2 hunks)
  • tests/VCS/Adapter/GitHubTest.php (2 hunks)
🔇 Additional comments (2)
src/VCS/Adapter/Git/GitHub.php (1)

695-695: LGTM!

The addition of affectedFiles to the return payload is appropriate and consistent with the structure of the push event result.

tests/VCS/Adapter/GitHubTest.php (1)

57-87: LGTM!

The test payload correctly includes a commits array with realistic file changes (added, removed, and modified), which aligns with the GitHub webhook format for push events.

@Meldiron Meldiron requested a review from Copilot December 16, 2025 14:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for tracking affected files in GitHub push webhook events. The implementation collects all files that were added, removed, or modified across all commits in a push event and exposes them through a new affectedFiles array in the event response.

Key Changes:

  • Added logic to collect and deduplicate affected files from all commits in a push event
  • Updated test fixtures to include commit details with file changes
  • Added assertions to verify the affected files are correctly extracted and returned

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/VCS/Adapter/Git/GitHub.php Implements logic to collect affected files from commits and adds affectedFiles to the push event response
tests/VCS/Adapter/GitHubTest.php Adds test fixture data with commit file changes and assertions to validate affected files tracking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/VCS/Adapter/Git/GitHub.php (1)

654-667: Good progress on performance optimization; consider completing the previous review suggestions.

The associative array approach successfully addresses the O(n²) performance concern raised in previous reviews. The null coalescing operators add basic validation.

However, the previous review suggested explicit is_array() checks for defensive programming. In PHP 8+, if $payload['commits'] is set to a non-array value (e.g., a string), the foreach will throw a TypeError. While GitHub's webhook payloads should be well-formed, adding the explicit check makes the code more resilient to malformed input.

Additionally, the previous review recommended using a generic variable name like $file instead of $added, $removed, $modified, since all three loops are simply adding file paths to the same deduplicated set.

Consider applying the approach from the previous review to strengthen validation and improve clarity:

 $affectedFiles = [];
-foreach (($payload['commits'] ?? []) as $commit) {
-    foreach (($commit['added'] ?? []) as $added) {
-        $affectedFiles[$added] = true;
+$commits = $payload['commits'] ?? [];
+if (is_array($commits)) {
+    foreach ($commits as $commit) {
+        foreach (($commit['added'] ?? []) as $file) {
+            $affectedFiles[$file] = true;
+        }
+        foreach (($commit['removed'] ?? []) as $file) {
+            $affectedFiles[$file] = true;
+        }
+        foreach (($commit['modified'] ?? []) as $file) {
+            $affectedFiles[$file] = true;
+        }
     }
-
-    foreach (($commit['removed'] ?? []) as $removed) {
-        $affectedFiles[$removed] = true;
-    }
-
-    foreach (($commit['modified'] ?? []) as $modified) {
-        $affectedFiles[$modified] = true;
-    }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d804f60 and 3b56bac.

📒 Files selected for processing (1)
  • src/VCS/Adapter/Git/GitHub.php (2 hunks)
🔇 Additional comments (1)
src/VCS/Adapter/Git/GitHub.php (1)

689-689: LGTM!

The array_keys() call correctly extracts the deduplicated file paths from the associative array.

@Meldiron Meldiron merged commit 44035d3 into main Dec 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants