feat(forge): add undismiss review helper
Some checks failed
Security Scan / security (push) Failing after 14s
Test / test (push) Has been cancelled

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 13:51:08 +00:00
parent c394ef2a9c
commit e0ff9d2c28
4 changed files with 36 additions and 2 deletions

View file

@ -90,7 +90,7 @@ The `gitea/` package mirrors this using `GITEA_URL`/`GITEA_TOKEN` and `gitea.*`
| `repos.go` | `ListOrgRepos`, `ListOrgReposIter`, `ListUserRepos`, `ListUserReposIter`, `GetRepo`, `CreateOrgRepo`, `DeleteRepo`, `MigrateRepo` |
| `issues.go` | `ListIssues`, `ListIssuesIter`, `GetIssue`, `CreateIssue`, `EditIssue`, `AssignIssue`, `ListPullRequests`, `ListPullRequestsIter`, `GetPullRequest`, `CreateIssueComment`, `ListIssueComments`, `ListIssueCommentsIter`, `CloseIssue` |
| `labels.go` | `ListOrgLabels`, `ListOrgLabelsIter`, `ListRepoLabels`, `ListRepoLabelsIter`, `CreateRepoLabel`, `GetLabelByName`, `EnsureLabel`, `AddIssueLabels`, `RemoveIssueLabel` |
| `prs.go` | `MergePullRequest`, `SetPRDraft`, `ListPRReviews`, `GetCombinedStatus`, `DismissReview` |
| `prs.go` | `MergePullRequest`, `SetPRDraft`, `ListPRReviews`, `GetCombinedStatus`, `DismissReview`, `UndismissReview` |
| `webhooks.go` | `CreateRepoWebhook`, `ListRepoWebhooks` |
| `orgs.go` | `ListMyOrgs`, `GetOrg`, `CreateOrg` |
| `meta.go` | `GetPRMeta`, `GetCommentBodies`, `GetIssueBody` |

View file

@ -4,9 +4,9 @@ package forge
import (
"bytes"
"iter"
fmt "dappco.re/go/core/scm/internal/ax/fmtx"
json "dappco.re/go/core/scm/internal/ax/jsonx"
"iter"
"net/http"
"net/url"
"strconv"
@ -158,3 +158,13 @@ func (c *Client) DismissReview(owner, repo string, index, reviewID int64, messag
}
return nil
}
// UndismissReview removes a dismissal from a pull request review.
// Usage: UndismissReview(...)
func (c *Client) UndismissReview(owner, repo string, index, reviewID int64) error {
_, err := c.api.UnDismissPullReview(owner, repo, index, reviewID)
if err != nil {
return log.E("forge.UndismissReview", "failed to undismiss review", err)
}
return nil
}

View file

@ -153,6 +153,23 @@ func TestClient_DismissReview_Bad_ServerError_Good(t *testing.T) {
assert.Contains(t, err.Error(), "failed to dismiss review")
}
func TestClient_UndismissReview_Good(t *testing.T) {
client, srv := newTestClient(t)
defer srv.Close()
err := client.UndismissReview("test-org", "org-repo", 1, 1)
require.NoError(t, err)
}
func TestClient_UndismissReview_Bad_ServerError_Good(t *testing.T) {
client, srv := newErrorServer(t)
defer srv.Close()
err := client.UndismissReview("test-org", "org-repo", 1, 1)
assert.Error(t, err)
assert.Contains(t, err.Error(), "failed to undismiss review")
}
func TestClient_SetPRDraft_Good_Request_Good(t *testing.T) {
var method, path string
var payload map[string]any

View file

@ -304,6 +304,13 @@ func newForgejoMux() *http.ServeMux {
})
})
// Undismiss review.
mux.HandleFunc("/api/v1/repos/test-org/org-repo/pulls/1/reviews/1/undismissals", func(w http.ResponseWriter, r *http.Request) {
jsonResponse(w, map[string]any{
"id": 1, "state": "open",
})
})
// Generic fallback — handles PATCH for SetPRDraft and other unmatched routes.
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Handle PATCH requests (SetPRDraft).