Skip to content

fix: resolve testGetPullRequestFiles failures for Forgejo and Gogs#83

Merged
Meldiron merged 9 commits intoutopia-php:copilot/add-gogs-adapter-and-tests-againfrom
jaysomani:fix/gogs-final
Apr 3, 2026
Merged

fix: resolve testGetPullRequestFiles failures for Forgejo and Gogs#83
Meldiron merged 9 commits intoutopia-php:copilot/add-gogs-adapter-and-tests-againfrom
jaysomani:fix/gogs-final

Conversation

@jaysomani
Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR introduces getPullRequestFiles across the adapter hierarchy — adding the abstract method to Adapter.php, implementing paginated versions in GitHub and Gitea (inherited by Forgejo and Gogs), and wiring up integration tests for each. It fixes the previously-failing testGetPullRequestFiles for Forgejo and Gogs by having Forgejo inherit Gitea's implementation and Gogs skip the test, which is the correct approach given Gogs's API limitations.

Key changes:

  • Adapter.php: New getPullRequestFiles abstract method added to the interface.
  • Gitea.php: Paginated implementation with a $maxPages = 100 guard and HTTP status-code check; also contains a stale commented-out line in createRepository.
  • GitHub.php: Paginated implementation via while (true) loop; lacks the status-code error check and max-page bound present in the Gitea version (previously flagged in review threads).
  • Both GitHub and Gitea implementations pass $response['body'] ?? [] directly into array_merge without an is_array() guard — if body is a non-null, non-array value (e.g. false on JSON decode failure), PHP 8 will throw a TypeError.
  • Test coverage is solid: Gitea/Forgejo use isolated, self-contained integration tests; Gogs correctly skips; GitHub follows the existing pattern of testing against a fixed public PR.

Confidence Score: 4/5

Safe to merge once the is_array() guard is added to both adapter implementations; the TypeError risk is real on PHP 8 under abnormal API responses.

Two P1 findings remain: both GitHub::getPullRequestFiles and Gitea::getPullRequestFiles pass $response['body'] directly into array_merge without verifying it is actually an array, which will throw a PHP 8 TypeError if the body is ever false or another non-array non-null value. One P2 finding (stale commented-out dead code in Gitea::createRepository) is also present. The core feature logic is otherwise sound and well-structured.

src/VCS/Adapter/Git/GitHub.php and src/VCS/Adapter/Git/Gitea.php — both need an is_array() guard before array_merge in getPullRequestFiles.

Important Files Changed

Filename Overview
src/VCS/Adapter.php Adds abstract getPullRequestFiles method to the base adapter contract — clean addition that enforces the interface across all implementations.
src/VCS/Adapter/Git/GitHub.php Adds paginated getPullRequestFiles; missing error handling on API failures (previously flagged), no max-page guard (previously flagged), and a potential PHP 8 TypeError if body is non-array non-null (new).
src/VCS/Adapter/Git/Gitea.php Adds paginated getPullRequestFiles with a proper status-code check and max-page guard; has a stale commented-out line in createRepository (dead code referencing undefined $body) and the same potential PHP 8 TypeError before array_merge.
tests/VCS/Adapter/GiteaTest.php Adds a self-contained integration test that creates a fresh repo, branch, and PR before asserting on file list — well-structured and cleans up after itself.
tests/VCS/Adapter/GitHubTest.php Adds testGetPullRequestFiles against a hardcoded external PR (vermakhushboo/basic-js-crud#1); consistent with the existing testGetPullRequest pattern in the file, but still relies on external state that could drift.
tests/VCS/Adapter/GogsTest.php Correctly skips testGetPullRequestFiles for Gogs, consistent with other unsupported-API skips already present in the file.
tests/VCS/Base.php Adds testGetPullRequestFiles as an abstract method, enforcing implementation in all concrete test classes — correct contract change.

Reviews (2): Last reviewed commit: "removed dead code" | Re-trigger Greptile

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f09164da88

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Meldiron Meldiron added the test Enables E2E tests in CI/CD label Apr 3, 2026
@Meldiron Meldiron added test Enables E2E tests in CI/CD and removed test Enables E2E tests in CI/CD labels Apr 3, 2026
@Meldiron Meldiron merged commit 90e6a4f into utopia-php:copilot/add-gogs-adapter-and-tests-again Apr 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Enables E2E tests in CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants