feat: Add Gitea git operations and user endpoints#71
feat: Add Gitea git operations and user endpoints#71jaysomani wants to merge 6 commits intoutopia-php:mainfrom
Conversation
- Implement updateCommitStatus for CI/CD status updates - Implement generateCloneCommand for branch/commit/tag cloning - Implement getUser to fetch user information - Implement createTag to create repository tags - Mark getInstallationRepository as not applicable (throws exception) - Add comprehensive tests for all methods - Include error cases and try/finally cleanup - Follow PR utopia-php#64 null safety pattern
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe changes implement five new public methods in the Gitea VCS adapter class to support version control operations: user information retrieval, repository tag creation, commit status updates, clone command generation with sparse checkout support, and handling of installation repository requests (which are not applicable to Gitea). Corresponding test coverage is added for all new methods, including multiple scenarios for clone commands across branch, commit, and tag references, error handling cases, and user and tag operations. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip You can generate walkthrough in a markdown collapsible section to save space.Enable the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6b99991ab
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tests/VCS/Adapter/GiteaTest.php (1)
466-467: Remove tautological assertion intestUpdateCommitStatus.
assertTrue(true)does not validate behavior; rely on no-exception flow (or add a concrete status verification assertion if available).Suggested patch
- // If we get here without exception, test passes - $this->assertTrue(true); + // No exception means status update call succeeded.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/VCS/Adapter/GiteaTest.php` around lines 466 - 467, Remove the tautological assertion in testUpdateCommitStatus: locate the test method testUpdateCommitStatus in tests/VCS/Adapter/GiteaTest.php and delete the line containing $this->assertTrue(true); either relying on the test passing by not throwing an exception or replacing it with a meaningful assertion that verifies the commit status (for example, assertEquals/assertSame against the updated status returned by the method under test or by calling the adapter's status retrieval method if available).src/VCS/Adapter/Git/Gitea.php (1)
138-140: Optional cleanup: mark the interface-required parameter as intentionally unused.Line 138 keeps
$repositoryNameonly for signature compatibility; consider renaming to$_repositoryNameto silence PHPMD intentfully.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/VCS/Adapter/Git/Gitea.php` around lines 138 - 140, The getInstallationRepository method still declares an unused parameter $repositoryName for interface compatibility; rename it to $_repositoryName (or prefix with underscore) in the method signature of getInstallationRepository to intentionally mark it unused and silence PHPMD, keeping the method body (throwing the Exception) unchanged so compatibility is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/VCS/Adapter/Git/Gitea.php`:
- Line 383: The user name is inserted directly into the path at the $url
assignment in Gitea.php which can break URLs with special characters; update the
$url construction to path-encode the username (use rawurlencode on $username)
before interpolation so the segment is safe, ensuring any references to $url in
methods like the Gitea API request callers remain unchanged.
- Around line 560-597: The git remote add origin command currently injects raw
$cloneUrl into the shell command (in the $commands array) which is unsafe and
must be wrapped with escapeshellarg($cloneUrl) before concatenation; also add a
default branch in the switch on $versionType to explicitly reject unsupported
values (throw an InvalidArgumentException or RuntimeException mentioning
$versionType and the allowed constants CLONE_TYPE_BRANCH, CLONE_TYPE_COMMIT,
CLONE_TYPE_TAG) so unknown clone types no longer silently do nothing; update the
entry that builds "git remote add origin {$cloneUrl}" to use the escaped value
and add a default: case to the switch that raises an exception.
---
Nitpick comments:
In `@src/VCS/Adapter/Git/Gitea.php`:
- Around line 138-140: The getInstallationRepository method still declares an
unused parameter $repositoryName for interface compatibility; rename it to
$_repositoryName (or prefix with underscore) in the method signature of
getInstallationRepository to intentionally mark it unused and silence PHPMD,
keeping the method body (throwing the Exception) unchanged so compatibility is
preserved.
In `@tests/VCS/Adapter/GiteaTest.php`:
- Around line 466-467: Remove the tautological assertion in
testUpdateCommitStatus: locate the test method testUpdateCommitStatus in
tests/VCS/Adapter/GiteaTest.php and delete the line containing
$this->assertTrue(true); either relying on the test passing by not throwing an
exception or replacing it with a meaningful assertion that verifies the commit
status (for example, assertEquals/assertSame against the updated status returned
by the method under test or by calling the adapter's status retrieval method if
available).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f0ec1072-cc08-4cbe-ad53-ae41e2289ca9
📒 Files selected for processing (2)
src/VCS/Adapter/Git/Gitea.phptests/VCS/Adapter/GiteaTest.php
Greptile SummaryThis PR implements four previously stubbed-out Gitea adapter methods — Key changes and issues:
Confidence Score: 2/5
Important Files Changed
Last reviewed commit: "Merge branch 'utopia..." |
Summary by CodeRabbit
New Features
Tests