Skip to content

Add UnapproveMergeRequest, GetDiffsAsync with unidiff, and draft notes API - #1123

Draft
louis-z wants to merge 4 commits into
mainfrom
add-unapprove-unidiff-draft-notes
Draft

Add UnapproveMergeRequest, GetDiffsAsync with unidiff, and draft notes API#1123
louis-z wants to merge 4 commits into
mainfrom
add-unapprove-unidiff-draft-notes

Conversation

@louis-z

@louis-z louis-z commented Jul 29, 2026

Copy link
Copy Markdown
Member

Three GitLab API gaps that were missing from NGitLab:

  1. IMergeRequestApprovalClient.UnapproveMergeRequest(): Reverses a prior approval by the authenticated user.

  2. IMergeRequestClient.GetDiffsAsync(iid, MergeRequestDiffQuery): When MergeRequestDiffQuery.Unidiff is true, returns diffs in standard unified diff format instead of the default GitLab-specific format.

  3. IMergeRequestClient.DraftNotes(iid) -> IMergeRequestDraftNoteClient: New IMergeRequestDraftNoteClient interface and implementation covering:

    • All (GET /draft_notes - list draft notes)
    • CreateAsync (POST /draft_notes)
    • PublishAllAsync (POST /draft_notes/bulk_publish)

All new public symbols are registered in PublicAPI.Unshipped.txt for all TFMs. Mock stubs throw NotImplementedException (consistent with other unimplemented mocks).

…t notes API

Three GitLab API gaps that were missing from NGitLab:

1. IMergeRequestApprovalClient.UnapproveMergeRequest()
   POST /projects/:id/merge_requests/:iid/unapprove
   Reverses a prior approval by the authenticated user.

2. IMergeRequestClient.GetDiffsAsync(iid, MergeRequestDiffQuery)
   MergeRequestDiffQuery.Unidiff controls the ?unidiff=true query param (GitLab 16.5+),
   which returns diffs in standard unified diff format instead of the default
   GitLab-specific format.

3. IMergeRequestClient.DraftNotes(iid) -> IMergeRequestDraftNoteClient
   New IMergeRequestDraftNoteClient interface and implementation covering:
   - All (GET /draft_notes - list draft notes)
   - CreateAsync (POST /draft_notes)
   - PublishAllAsync (POST /draft_notes/bulk_publish)

All new public symbols are registered in PublicAPI.Unshipped.txt for all TFMs.
Mock stubs throw NotImplementedException (consistent with other unimplemented mocks).

Co-Authored-By: Claude <noreply@anthropic.com>
@louis-z
louis-z force-pushed the add-unapprove-unidiff-draft-notes branch from 26cae7a to 12cc6e5 Compare July 29, 2026 18:24
@louis-z
louis-z requested review from Toa741 and msrouchou July 29, 2026 18:34
@louis-z
louis-z marked this pull request as ready for review July 29, 2026 18:34
@louis-z
louis-z requested a review from a team as a code owner July 29, 2026 18:34
… and draft notes

Covers the three new APIs added in the previous commit:

- MergeRequestApprovalClientTests: approve/unapprove roundtrip, and unapprove-when-not-approved
  is tolerated (GitLab may return a 401; we accept both outcomes)
- MergeRequestDiffsClientTests: GetDiffsAsync returns diffs, unidiff=true returns the same
  file count, and the unified diff content starts with standard markers
- MergeRequestDraftNoteClientTests: create appears in All, All is empty on a fresh MR,
  PublishAllAsync clears drafts and they surface as regular comments

All tests use the Docker integration pattern (GitLabTestContext + [NGitLabRetry]).

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread NGitLab.Tests/MergeRequest/MergeRequestDraftNoteClientTests.cs Outdated
Comment thread NGitLab.Tests/MergeRequest/MergeRequestApprovalClientTests.cs Outdated
Comment thread NGitLab.Mock/Clients/MergeRequestApprovalClient.cs
@louis-z
louis-z marked this pull request as draft July 30, 2026 11:55
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