Skip to content

Fix: branch list empty#90

Draft
Meldiron wants to merge 6 commits intomainfrom
fix-gitea-branch-list
Draft

Fix: branch list empty#90
Meldiron wants to merge 6 commits intomainfrom
fix-gitea-branch-list

Conversation

@Meldiron
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor Author

@Meldiron Meldiron left a comment

Choose a reason for hiding this comment

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

lgtm

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR fixes an edge case where Gitea returns an empty response body (instead of []) for the branches endpoint on a newly-created empty repository, causing listBranches to misbehave. The fix uses decode: false on the raw HTTP call and manually JSON-decodes the body. The PR also refactors CI to use a per-adapter matrix strategy with Docker Compose profiles, adds a pushed_at field to GitLab/Gitea repository responses, and adds a testListBranchesEmptyRepo regression test to the shared base.

  • GitLabTest.php is missing a markTestSkipped override for the new testListBranchesEmptyRepo — without it, the inherited base test will call listBranches (which throws Exception(\"Not implemented\")) and use the hardcoded 'test-kh' owner that doesn't exist in the GitLab test environment, breaking the gitlab test suite.

Confidence Score: 4/5

Safe to merge after adding the missing testListBranchesEmptyRepo skip override in GitLabTest.php.

The core listBranches fix is correct and well-tested. One P1 issue exists: the new base test will cause the GitLab PHPUnit suite to fail because the skip override was not added alongside the existing testListBranches skip. All other changes (CI matrix, docker-compose profiles, pushed_at normalization) look correct.

tests/VCS/Adapter/GitLabTest.php — needs a testListBranchesEmptyRepo override with markTestSkipped.

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/Gitea.php Core fix: listBranches now calls with decode: false and manually JSON-decodes the body, handling Gitea's edge case of returning an empty body (instead of []) for repos with no branches. One leftover commented-out line in createRepository.
tests/VCS/Adapter/GitLabTest.php Missing testListBranchesEmptyRepo skip override — the new Base test will run against GitLab, fail on the hardcoded 'test-kh' owner and the unimplemented listBranches, breaking the gitlab test suite.
tests/VCS/Base.php Added testListBranchesEmptyRepo covering the empty-repo branch-list edge case, plus pushed_at assertions in repository tests; logic is correct for Gitea/Forgejo/Gogs adapters.
src/VCS/Adapter/Git/GitLab.php Added pushed_at normalization in createRepository and getRepository by mapping last_activity_at; no issues found.
.github/workflows/tests.yml Switched to a fail-fast: false matrix strategy per adapter, scoping both Docker Compose profiles and PHPUnit test suites correctly.
docker-compose.yml Migrated service conditions from service_healthy to service_started with required: false, enabling profile-scoped startup so only the adapter under test is brought up.
tests/VCS/Adapter/GitHubTest.php Correctly skips testListBranchesEmptyRepo since GitHub always initialises a default branch on repo creation.
tests/VCS/Adapter/GiteaTest.php Added pushed_at assertions to repository tests; inherits testListBranchesEmptyRepo from Base correctly.
phpunit.xml Defines named test suites per adapter, enabling --testsuite <adapter> CLI usage in CI.
CONTRIBUTING.md Documents the per-adapter test workflow clearly.

Comments Outside Diff (1)

  1. tests/VCS/Adapter/GitLabTest.php, line 209-212 (link)

    P1 Missing testListBranchesEmptyRepo override

    Base::testListBranchesEmptyRepo was added in this PR but GitLabTest only skips testListBranches. Without a matching skip override, the inherited test will call createRepository('test-kh', …) (a hardcoded owner that doesn't exist in the GitLab environment) and then listBranches, which throws Exception("Not implemented"), causing the GitLab test suite to fail.

Reviews (2): Last reviewed commit: "Add more tests for Appwrite usecases" | Re-trigger Greptile

@Meldiron Meldiron marked this pull request as draft April 10, 2026 14:28
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.

1 participant