Repository navigation
Conversation
Introduce internal/forge/forgejo with core REST plus high-value methods (forks, commits, PR reviews, comments, branch protection, Actions secrets), DetectForge recognition for Forgejo hosts, and CLI/harness/repos wiring. Co-authored-by: Cursor <cursoragent@cursor.com>
PR Summary by QodoAdd Forgejo/Gitea client and forge selection support
AI Description
Diagram
High-Level Assessment
Files changed (16)
|
Code Review by Qodo 1. The harness test suite fails
|
| token: token, | ||
| baseURL: normalizeAPIBase("https://git.forge.internal"), |
There was a problem hiding this comment.
8. Default forgejo endpoint points at an internal host 📘 Rule violation ⛨ Security
New initializes baseURL to the literal internal host https://git.forge.internal instead of requiring a configured URL; the same host also appears in detect.go, the README and tests. When newForgeClient receives neither a manifest URL nor FORGEJO_API_URL or GITEA_API_URL, requests use that host and attach FORGEJO_TOKEN or GITEA_TOKEN in the Authorization header.
Agent Prompt
## Issue description
The Forgejo client defaults to a hardcoded internal hostname. When no manifest or environment URL is configured, requests use that host with the configured token.
## Fix Focus Areas
- internal/forge/forgejo/client.go[49-60]
- internal/cli/forge_client.go[77-88]
## Recommended Fix
Remove the literal default from `New` and set the base URL only from an explicit `WithBaseURL` option or an environment-derived value. In `newForgeClient`, return an error such as `set FORGEJO_API_URL or forge.url` when neither a manifest base URL nor `FORGEJO_API_URL` / `GITEA_API_URL` provides one. Remove the internal host from production logic, including `detect.go`, and update the README; use a placeholder such as `forge.example.com` in documentation and keep any internal-host examples confined to test fixtures.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| return "github", nil | ||
| case "gitlab.com": | ||
| return "gitlab", nil | ||
| case "git.forge.internal", "codeberg.org", "gitea.com": |
There was a problem hiding this comment.
9. Internal forgejo host hardcoded in forge detection 📘 Rule violation ⛨ Security
DetectForge maps the exact hostname git.forge.internal to the forgejo forge, so the organization's internal host is recognized by literal name in shipped logic. Any repository whose remote is on that private host is classified by this hardcoded entry, which must be changed in code whenever the internal host changes.
Agent Prompt
## Issue description
`DetectForge` hardcodes `git.forge.internal` as a Forgejo host. This is an environment-specific internal hostname in source code.
## Fix Focus Areas
- internal/forge/detect.go[25-35]
## Recommended Fix
Remove `git.forge.internal` from the `case` list. Rely on the existing substring match for `forgejo`/`gitea`, or accept an operator-supplied host list via config or `--forge`, so that no private hostname is shipped in code.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // CreateBranchFromSHA implements forge.Client. | ||
| func (c *LiveClient) CreateBranchFromSHA(ctx context.Context, owner, repo, branch, sha string) error { | ||
| payload := map[string]any{"new_branch_name": branch, "old_ref_name": sha} | ||
| // Forgejo: POST /repos/{owner}/{repo}/branches | ||
| payload = map[string]any{"new_branch_name": branch, "old_branch_name": ""} |
There was a problem hiding this comment.
10. New forgejo branch helper has untested dead code paths 📘 Rule violation ▣ Testability
CreateBranchFromSHA builds and then overwrites a payload map that is never sent, and its fallback path to the /branches endpoint is not exercised by any test. Several other new exported methods in repos.go (such as CreateChangeProposal, CreateIssue, DeleteFile) are also not referenced by any test in the package, so regressions in this code would pass go test unnoticed.
Agent Prompt
## Issue description
New logic in `internal/forge/forgejo/repos.go` (notably `CreateBranchFromSHA`, `CreateChangeProposal`, `CreateIssue`, `DeleteFile`) has no test that references it, and `CreateBranchFromSHA` contains a dead `payload` assignment that is overwritten before use.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[237-258]
- internal/forge/forgejo/client_test.go[1-55]
## Recommended Fix
Remove the dead first `payload` assignment in `CreateBranchFromSHA`. Add httptest-based tests that call `CreateBranchFromSHA` (both the `/git/refs` success path and the `/branches` fallback), `CreateChangeProposal`, `CreateIssue`, and `DeleteFile`, each asserting on the returned value or the request.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| payload := map[string]any{ | ||
| "event": event, | ||
| "body": body, | ||
| } |
There was a problem hiding this comment.
11. Misaligned review payload fails gofmt formatting 📘 Rule violation ✧ Quality
The map literal in CreatePullRequestReview pads "event": and "body": with extra spaces that gofmt would not produce, so the file is not canonically formatted. A gofmt-based lint step in `make lint` would report this file and fail the change.
Agent Prompt
## Issue description
The new file `internal/forge/forgejo/highvalue.go` has misaligned map literal and struct field spacing in several places, including the payload in `CreatePullRequestReview`, which gofmt would rewrite. The lint target may fail on this.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[285-288]
- internal/forge/forgejo/highvalue.go[249-255]
## Recommended Fix
Run `gofmt -w internal/forge/forgejo/*.go` and confirm `make lint` exits 0 before merge.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if token := os.Getenv("FORGEJO_TOKEN"); token != "" { | ||
| return token, nil | ||
| } | ||
| if token := os.Getenv("GITEA_TOKEN"); token != "" { |
There was a problem hiding this comment.
12. Forgejo setup variables are undocumented 📘 Rule violation ⚙ Maintainability
The PR adds the FORGEJO_TOKEN, GITEA_TOKEN, FORGEJO_API_URL and GITEA_API_URL environment variables, read in newForgeClient, and registers forgejo as an accepted forge key, but no file under docs/cli/ or docs/guides/ mentions any of them. The only token documentation in those folders covers GitHub and GitLab (docs/cli/README.md line 42, docs/cli/repos.md line 15), so a user installing against a Forgejo host has no documented variable to set and no documented --forge value to use.
Agent Prompt
Issue description
The PR adds Forgejo support to the CLI (`FORGEJO_TOKEN`, `GITEA_TOKEN`, `FORGEJO_API_URL`, `GITEA_API_URL`, and the `forgejo` forge key), but `docs/cli/README.md` and `docs/cli/repos.md` only describe GitHub and GitLab. Users have no documented way to authenticate or point the CLI at a Forgejo host.
Fix Focus Areas
- internal/cli/forge_client.go[32-35]
- internal/repos/manifest.go[36-39]
- docs/cli/README.md[42]
- docs/cli/repos.md[15]
Recommended Fix
In `docs/cli/README.md`, extend the token-resolution paragraph to list `FORGEJO_TOKEN` then `GITEA_TOKEN` for Forgejo, and note that `FORGEJO_API_URL` or `GITEA_API_URL` overrides the default host. In `docs/cli/repos.md`, add `forgejo` to the list of accepted forge values and state that the `--forge` flag accepts it. Keep the wording consistent with the existing GitLab entries.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| path := "/orgs/" + url.PathEscape(org) + "/repos?limit=100" | ||
| if _, err := c.do(ctx, http.MethodGet, path, nil, &raw); err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
25. Listings silently drop items past page one 🐞 Bug ≡ Correctness
ListOrgRepos, ListRepoPullRequests, ListOpenIssues, ListPullRequestCommits, ListPullRequestFiles/FileDiffs, and ListIssueComments each decode one response from a request with a fixed limit and never fetch another page. When a collection exceeds its first page—50 items by default under Forgejo’s MAX_RESPONSE_ITEMS cap—callers silently receive incomplete data, including manifest glob expansion and file diffs used to place inline review comments.
Agent Prompt
## Issue description
Forgejo list methods fetch only their first response page. With a default page-size cap of 50, larger collections are silently truncated for callers.
## Fix Focus Areas
- internal/forge/forgejo/client.go[168-186]
- internal/forge/forgejo/repos.go[319-330]
- internal/forge/forgejo/repos.go[367-379]
- internal/forge/forgejo/repos.go[428-446]
- internal/forge/forgejo/repos.go[488-499]
- internal/forge/forgejo/highvalue.go[232-276]
- internal/forge/forgejo/highvalue.go[308-334]
## Recommended Fix
Add a reusable pagination helper for these list methods that requests successive pages with `limit=50`, combines their results, and stops when the server indicates there are no further results, using a short page or the absence of `Link: rel="next"` as applicable. Add tests with collections exceeding one page.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if err != nil && strings.Contains(err.Error(), "409") { | ||
| return nil | ||
| } | ||
| // already exists often returns 422 | ||
| if err != nil && (strings.Contains(err.Error(), "422") || strings.Contains(strings.ToLower(err.Error()), "already")) { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
27. Label errors are swallowed or missed 🐞 Bug ☼ Reliability
EnsureLabel looks for "409" in err.Error(), but do() maps 409 to forge.ErrConflict, whose message is just "conflict", so that branch never matches. The 422/already substring check also swallows unrelated validation failures and any error whose URL path happens to contain "422", and AddIssueLabels discards EnsureLabel errors entirely.
Agent Prompt
## Issue description
EnsureLabel tells failures apart by matching substrings of the error text, which misses 409 and swallows unrelated 422 errors.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[449-470]
## Recommended Fix
GET the repo's labels and skip creation when the name already exists. For create errors, use `forge.IsConflict(err)` rather than string matching. Return or log the errors in AddIssueLabels instead of discarding them.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| p := "/repos/" + escapePath(owner, repo) + "/branch_protections/" + url.PathEscape(branch) | ||
| code, err := c.do(ctx, http.MethodGet, p, nil, &raw) | ||
| if err != nil { | ||
| if code == http.StatusNotFound || forge.IsNotFound(err) { | ||
| return nil, nil | ||
| } | ||
| return nil, err |
There was a problem hiding this comment.
26. Wildcard-protected branches read as unprotected 🐞 Bug ≡ Correctness
GetProtectedBranch calls /branch_protections/{branch}, but Forgejo looks this endpoint up by
rule name, not by the branch it matches. A branch covered by a glob rule such as release/*, or by
a rule with a different name, gets a 404 and is reported as unprotected via return nil, nil.
Agent Prompt
## Issue description
The branch_protections/{name} endpoint is keyed by rule name, so branches protected by a glob rule are reported as unprotected.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[352-382]
## Recommended Fix
Call GET /repos/{o}/{r}/branches/{branch} and use its `protected` field. Alternatively, list the rules and match the branch against each rule's glob. Return nil only when no rule matches.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // FindExistingFork is not yet implemented for Forgejo. | ||
| func (c *LiveClient) DeleteProjectServiceAccount(ctx context.Context, owner, repo string, userID int) error { |
There was a problem hiding this comment.
28. Stub comments name the wrong methods 🐞 Bug ⚙ Maintainability
Several doc comments in stubs.go describe a different method than the one below them, e.g. "FindExistingFork is not yet implemented" above DeleteProjectServiceAccount, and "IsProtectedBranch is not yet implemented" above ListProtectedTags, even though those named methods are implemented in highvalue.go. CreateBranchFromSHA also builds two payload maps that are never sent, so a later reader can't tell which methods are real and which request is actually made.
Agent Prompt
## Issue description
The stub doc comments name the wrong methods, and CreateBranchFromSHA has dead assignments.
## Fix Focus Areas
- internal/forge/forgejo/stubs.go[11-26]
- internal/forge/forgejo/stubs.go[116-162]
- internal/forge/forgejo/stubs.go[206-207]
- internal/forge/forgejo/repos.go[238-246]
## Recommended Fix
Rename each comment so it matches the function below it. In CreateBranchFromSHA, remove the unused `payload` assignments.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // abstraction design (see https://github.com/fullsend-ai/fullsend/pull/6237). | ||
| "jira": true, | ||
| // Forgejo/Gitea API client (ForgeOps FACTORY-FULLSEND-FORGEJO-CLIENT-001). | ||
| "forgejo": true, |
There was a problem hiding this comment.
7. Forgejo agents fail before launch 🔗 Cross-repo conflict ≡ Correctness
validForgeKeys now accepts forgejo, but fullsend-ai/agents has no Forgejo harness configuration to supply forge credentials and FULLSEND_FORGE, and its pre-scripts support only GitHub and GitLab. When an agents code or review harness is selected with --forge forgejo, its pre-script fails before the sandbox can run or use the new client.
Agent Prompt
## Issue description
The platform accepts Forgejo for agent runs, but the agents repository has no Forgejo harness configuration and its pre-scripts reject that forge.
## Fix Focus Areas
- internal/harness/forge.go[50-51]
- /cross_repos/agents/harness/code.yaml[113-177]
- /cross_repos/agents/harness/review.yaml[105-164]
- /cross_repos/agents/scripts/lib/review-ops.lib.sh[12-23]
- /cross_repos/agents/scripts/pre-code.sh[1658-1664]
## Recommended Fix
Add Forgejo overlays, credentials, and script dispatch in fullsend-ai/agents before enabling its harness key in fullsend, or defer accepting that key until the agents integration is ready.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Thank you for your interest in contributing to fullsend, @MrGeek0s. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
Summary
internal/forge/forgejoimplementingforge.Clientfor Forgejo/Gitea API v1 (core REST + high-value methods; remaining GitLab/Actions workflow methods returnErrNotSupported).DetectForgefor Forgejo/Gitea hosts (includinggit.forge.internal).newForgeClient("forgejo")viaFORGEJO_TOKEN/GITEA_TOKEN, and acceptsforgejoas a harness/repos forge key.Developed and validated against a private Forgejo instance in the ForgeOps lab; unit tests included.
Test plan
go test ./internal/forge/forgejo/go test ./internal/forge/ -run TestDetectForgego test ./internal/cli/ -run TestNewForgeClient_ForgejoFORGEJO_TOKEN(-tags live_forgejo)