Skip to content

feat(gitlab): add getPullRequest, getPullRequestFiles, getPullRequestFromBranch, createComment, getComment, updateComment and getUser#94

Open
jaysomani wants to merge 5 commits intoutopia-php:mainfrom
jaysomani:feat/gitlab-adapter-pullrequest
Open

feat(gitlab): add getPullRequest, getPullRequestFiles, getPullRequestFromBranch, createComment, getComment, updateComment and getUser#94
jaysomani wants to merge 5 commits intoutopia-php:mainfrom
jaysomani:feat/gitlab-adapter-pullrequest

Conversation

@jaysomani
Copy link
Copy Markdown
Contributor

Summary

Implements the remaining pull request, comment, and user methods for the GitLab adapter, completing the full adapter implementation.

Changes

New methods implemented

  • getPullRequest — fetches a merge request by iid, normalized to match Gitea/GitHub shape
  • getPullRequestFiles — fetches changed files using /diffs endpoint with patch_id_sha polling to handle GitLab's async diff processing
  • getPullRequestFromBranch — finds an open merge request by source branch
  • createComment — creates a note on a merge request via GitLab notes API
  • getComment — retrieves a note by ID, searching across all MRs in the repository
  • updateComment — updates an existing note by ID
  • getUser — fetches a user by username via GitLab users search API

Tests added

  • Full test coverage for all new methods including invalid/edge case scenarios
  • GitLab-specific tests: testGetEventPushMatchesCheckoutSha, testValidateWebhookEventUsesPlainToken, testCreateOrganization
  • Parity tests matching Gitea: testGetUser, testGetUserWithInvalidUsername, testCreatePrivateRepository, testGetRepositoryWithNonExistingOwner, testCreateRepositoryWithInvalidName, testDeleteRepositoryTwiceFails, testDeleteNonExistingRepositoryFails, testGetPullRequestFromBranchNoPR, testCreateCommentInvalidPR, testGetCommentInvalidId

Notes

  • GitLab notes (comments) are scoped to merge requests — getComment and updateComment search across all MRs to find the note by ID since the MR iid is not stored with the comment ID
  • getPullRequestFiles uses patch_id_sha polling per GitLab's official documentation recommendation for async diff processing
  • getUser returns username field (not login like Gitea/GitHub) — this is a GitLab API difference
  • This PR is based on feat/gitlab-adapter-webhooks and will need a rebase once that PR merges

@jaysomani jaysomani marked this pull request as ready for review April 27, 2026 06:06
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR implements the remaining GitLab adapter methods (getPullRequest, getPullRequestFiles, getPullRequestFromBranch, createComment, getComment, updateComment, getUser) and activates the corresponding integration tests. It also introduces a paginated findMrIidForNote helper that correctly addresses the previously flagged MR-list truncation and spurious-PUT issues.

Confidence Score: 5/5

Safe to merge; no P0 or P1 issues found — only two P2 style/performance suggestions.

All findings are P2: a redundant API call in getComment and a missing early-exit guard in the getPullRequestFiles polling loop. Both leave behavior functionally correct, just slightly inefficient. Previously flagged P1s (pagination gaps, spurious PUTs) are resolved by the new findMrIidForNote helper.

No files require special attention.

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/GitLab.php Implements getPullRequest, getPullRequestFiles, getPullRequestFromBranch, createComment, getComment, updateComment, getUser, and a helper findMrIidForNote with pagination; addresses previous pagination/N-PUT issues; minor redundant fetch in getComment and missing error-check in polling loop.
tests/VCS/Adapter/GitLabTest.php Replaces all previously-skipped stubs with real integration tests; adds new parity and edge-case tests; uses assertEventually for async-sensitive assertions; overall solid test coverage for new methods.

Reviews (5): Last reviewed commit: "Merge branch 'utopia-php:main' into feat..." | Re-trigger Greptile

Comment thread src/VCS/Adapter/Git/GitLab.php Outdated
Comment thread src/VCS/Adapter/Git/GitLab.php Outdated
Comment thread src/VCS/Adapter/Git/GitLab.php Outdated
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: 76df5e76dd

ℹ️ 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".

Comment thread src/VCS/Adapter/Git/GitLab.php Outdated
Comment thread src/VCS/Adapter/Git/GitLab.php
Comment thread src/VCS/Adapter/Git/GitLab.php
@jaysomani jaysomani marked this pull request as draft April 27, 2026 06:53
@jaysomani jaysomani marked this pull request as ready for review April 27, 2026 08:41
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: 8a688e865e

ℹ️ 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".

Comment thread src/VCS/Adapter/Git/GitLab.php
Comment thread src/VCS/Adapter/Git/GitLab.php
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