Repository navigation
Conversation
Implement forge.Client for Forgejo/Gitea API v1 with CLI DetectForge wiring, Actions/reactions/review-thread coverage, and review fixes (no hardcoded default host, nil scopes, no GitHub mint fallthrough). Signed-off-by: mrgeek <yassine.elfhama@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: mrgeek <yassine.elfhama@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
PR Summary by QodoAdd Forgejo/Gitea forge client and CLI integration
AI Description
Diagram
High-Level Assessment
Files changed (20)
|
Code Review by Qodo 1. Agent approvals land as invisible pending reviews
|
| c := New(tok, WithBaseURL("https://git.forge.internal/api/v1")) | ||
| u, err := c.GetAuthenticatedUser(context.Background()) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| r, err := c.GetRepo(context.Background(), "forgeops-ai", "forge-platform") |
There was a problem hiding this comment.
7. Smoke test exposes internal forgejo host 📘 Rule violation ⛨ Security
The build-tagged live smoke test hardcodes https://git.forge.internal/api/v1 as the API base, along with the organization forgeops-ai and repository forge-platform, instead of reading them from FORGEJO_API_URL or using placeholders. The same internal host is also committed in internal/cli/forge_client_test.go, so anyone with repository access can see the internal endpoint and project names, and anyone who runs the live_forgejo tag is pointed at that instance.
Agent Prompt
## Issue description
The live Forgejo smoke test in `internal/forge/forgejo/live_smoke_test.go` hardcodes an internal host (`git.forge.internal`), an organization (`forgeops-ai`), and a repository (`forge-platform`). Rule 1062040 forbids committing environment-specific internal identifiers to source.
## Fix Focus Areas
- internal/forge/forgejo/live_smoke_test.go[16-21]
- internal/cli/forge_client_test.go[109-114]
## Recommended Fix
In `live_smoke_test.go`, replace the hardcoded base URL with `os.Getenv("FORGEJO_API_URL")` and skip the test when it is empty, the same way it already skips when `FORGEJO_TOKEN` is unset. Read the org and repo names from env vars such as `FORGEJO_SMOKE_ORG` and `FORGEJO_SMOKE_REPO`, and skip when they are unset. In `forge_client_test.go`, replace the `https://git.forge.internal` fixture with a neutral placeholder such as `https://forgejo.example.com`, since the test only asserts URL normalization.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // CommitFilesToBranch implements forge.Client via sequential contents API. | ||
| // Not atomic: a mid-batch failure may leave earlier file writes committed. | ||
| func (c *LiveClient) CommitFilesToBranch(ctx context.Context, owner, repo, branch, message string, files []forge.TreeFile) (bool, error) { |
There was a problem hiding this comment.
2. Failed batches leave files committed 🐞 Bug ≡ Correctness
CommitFilesToBranch writes or deletes each TreeFile in a separate Contents API operation despite the interface's atomic-commit contract. If a later operation fails, earlier files remain committed even though the method returns an error for the batch.
Agent Prompt
## Issue description
Sequential file writes can leave a partially applied multi-file commit.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[135-168]
## Recommended Fix
Build one commit containing the complete set of changes and update the branch once. If the Forgejo API cannot provide that guarantee, return an explicit unsupported error rather than reporting partial writes as an implementation of the atomic method.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if err := c.CreateOrUpdateFileOnBranch(ctx, owner, repo, branch, f.Path, message, content); err != nil { | ||
| return changed, err | ||
| } | ||
| changed = true |
There was a problem hiding this comment.
9. Unchanged files create extra commits 🐞 Bug ≡ Correctness
CommitFilesToBranch sends every non-delete file to CreateOrUpdateFileOnBranch and sets changed without comparing its content. Repeating a batch whose files already contain the requested bytes therefore creates commits instead of returning (false, nil) as the shared method promises.
Agent Prompt
## Issue description
The batch method treats unchanged file content as a new change.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[137-168]
- internal/forge/forgejo/repos.go[128-135]
## Recommended Fix
Compare requested bytes with existing content on the target branch, omit unchanged entries, and return `(false, nil)` when nothing needs to change. Preserve the atomic batch guarantee separately.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| content, err := f.Bytes() | ||
| if err != nil { | ||
| return changed, err | ||
| } | ||
| if err := c.CreateOrUpdateFileOnBranch(ctx, owner, repo, branch, f.Path, message, content); err != nil { |
There was a problem hiding this comment.
10. Executable files lose their requested mode 🐞 Bug ≡ Correctness
CommitFilesToBranch passes only a file's bytes to a Contents API write and discards TreeFile.Mode. A batch containing a new 100755 script cannot create it with the executable mode requested by the caller.
Agent Prompt
## Issue description
The batch writer ignores executable-file mode from `TreeFile`.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[159-166]
- internal/forge/forgejo/repos.go[93-106]
## Recommended Fix
Use a commit mechanism that records each tree entry's requested mode, including `100755`. Reject unsupported modes explicitly rather than silently creating files with different permissions.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // GetRef implements forge.Client. | ||
| func (c *LiveClient) GetRef(ctx context.Context, owner, repo, ref string) (string, error) { | ||
| ref = strings.TrimPrefix(ref, "refs/heads/") | ||
| return c.GetBranchRef(ctx, owner, repo, ref) |
There was a problem hiding this comment.
8. Valid tags cannot be resolved 🐞 Bug ≡ Correctness
GetRef strips only refs/heads/ and sends every remaining ref to the branch endpoint. Callers passing the documented heads/main or tags/v0 forms consequently request nonexistent branches instead of resolving those refs.
Agent Prompt
## Issue description
`GetRef` interprets documented ref paths as literal branch names.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[218-221]
## Recommended Fix
Normalize supported `heads/` and `tags/` forms and query the corresponding Forgejo git-ref endpoint, preserving not-found errors for missing refs.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| var raw []apiRepo | ||
| 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.
16. Org repo and pr lists silently truncate 🐞 Bug ☼ Reliability
ListOrgRepos sends one request with limit=100, and ListRepoPullRequests/ListOpenIssues send one with limit=50. None of them paginate. Forgejo caps page size at MAX_RESPONSE_ITEMS (50 by default), so orgs with more repos, PRs or issues than that get partial results with no error, and enrollment/discovery code skips the rest.
Agent Prompt
## Issue description
Several list methods fetch only the first page, and Forgejo caps the page size, so results are silently truncated.
## Fix Focus Areas
- internal/forge/forgejo/client.go[172-190]
- internal/forge/forgejo/repos.go[314-325]
- internal/forge/forgejo/repos.go[424-442]
## Recommended Fix
Loop over `page=1..N` with `limit=50` and stop when a page returns fewer than 50 items. Apply the same bounded pattern used in `ListRepoVariables`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // Forgejo/Gitea API client (ForgeOps FACTORY-FULLSEND-FORGEJO-CLIENT-001). | ||
| "forgejo": true, |
There was a problem hiding this comment.
17. Status reconciliation on forgejo hits github 🐞 Bug ≡ Correctness
Adding forgejo to validForgeKeys lets detectForgePlatform accept --forge forgejo, but reconcile-status sends every non-GitLab forge to reconcileGitHubClient. With that flag, reconciliation attempts GitHub authentication and may update a same-named GitHub repository or fail confusingly, rather than rejecting unsupported Forgejo reconciliation as setupStatusNotifier does.
Agent Prompt
## Issue description
`reconcile-status --forge forgejo` enters the GitHub fallback, potentially targeting the wrong forge instead of rejecting unsupported reconciliation.
## Fix Focus Areas
- internal/harness/forge.go[50-51]
- internal/cli/reconcilestatus.go[143-161]
## Recommended Fix
Before the GitHub branch, explicitly reject Forgejo with `return fmt.Errorf("status reconciliation is not supported for forgejo yet")`, or add a Forgejo reconciliation branch using a Forgejo client if reconciliation is supported. Test `--forge forgejo` and audit other `== "gitlab"`-else-GitHub branches for the same fallback.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| var content string | ||
| for _, r := range reactions { | ||
| if r.ID == reactionID { | ||
| content = r.Content | ||
| break | ||
| } | ||
| } | ||
| if content == "" { | ||
| return fmt.Errorf("delete issue reaction %d: %w", reactionID, forge.ErrNotFound) | ||
| } | ||
| p := "/repos/" + escapePath(owner, repo) + "/issues/" + strconv.Itoa(number) + "/reactions" | ||
| _, err = c.do(ctx, http.MethodDelete, p, map[string]any{"content": content}, nil) | ||
| return err |
There was a problem hiding this comment.
18. Deleting a reaction can remove the bot's own one 🐞 Bug ≡ Correctness
DeleteIssueReaction and DeleteIssueCommentReaction match a synthetic ID containing the reaction's user but discard that user before sending a DELETE identified only by content. When the ID belongs to someone else, Forgejo applies the DELETE to the authenticated account, removing its reaction with the same content or doing nothing while the method still returns success.
Agent Prompt
## Issue description
Reaction deletion matches a user-specific synthetic ID, but the content-only DELETE acts on the authenticated user's reaction instead of necessarily acting on the matched reaction.
## Fix Focus Areas
- internal/forge/forgejo/actions_reactions.go[60-79]
- internal/forge/forgejo/actions_reactions.go[95-113]
## Recommended Fix
Resolve the authenticated user's login and allow content-based deletion only when the matched reaction belongs to that user. Otherwise, return an error, such as ErrNotSupported or a forbidden error. Apply the check to both issue and issue-comment reactions, and test the case where different users reacted with the same content.
ⓘ 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.
5. Forgejo agent runs fail in scripts 🔗 Cross-repo conflict ≡ Correctness
ValidForgePlatform now accepts forgejo, but the agents repository has no Forgejo harness overlay or script dispatcher branch. When a Codeberg or Gitea remote selects the new forge, the code and fix harnesses supply no Forgejo-specific environment, and their post-scripts reject the forge.
Agent Prompt
## Issue description
Forgejo is accepted as an agent forge, but agents harnesses and post-scripts support only GitHub and GitLab.
## Fix Focus Areas
- internal/harness/forge.go[47-51]
- /cross_repos/agents/harness/code.yaml[111-160]
- /cross_repos/agents/scripts/lib/code-ops.lib.sh[17-26]
## Recommended Fix
Add Forgejo overlays and operation dispatch in agents, including the fix harness and scripts, before enabling Forgejo agent runs; otherwise keep unsupported runs blocked explicitly.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| } else if forgePlatform == repos.ForgeForgejo { | ||
| // Forgejo has no GitHub App mint endpoint; use FORGEJO_TOKEN / GITEA_TOKEN directly. | ||
| mintCleanup = func() {} |
There was a problem hiding this comment.
6. Forgejo scripts lack push credentials 🔗 Cross-repo conflict ≡ Correctness
runAgent skips minting for Forgejo but does not resolve FORGEJO_TOKEN or GITEA_TOKEN and export the credential as PUSH_TOKEN to the runner environment. When only the documented Forgejo credential is configured, the agents repository’s code and fix post-scripts reach their required PUSH_TOKEN check without a token, while the sandbox may instead inherit an ambient GitHub token.
Agent Prompt
## Issue description
Forgejo client authentication can use `FORGEJO_TOKEN` or `GITEA_TOKEN`, but the agent run does not make that credential available as the `PUSH_TOKEN` required by its post-scripts.
## Fix Focus Areas
- internal/cli/run.go[1050-1055]
- internal/cli/forge_client.go[29-38]
- /cross_repos/agents/harness/code.yaml[89-94]
- /cross_repos/agents/scripts/post-code.sh[3627-3631]
## Recommended Fix
Add Forgejo agent credential setup analogous to `applyGitLabAgentCredentials`: resolve `FORGEJO_TOKEN` or `GITEA_TOKEN`, fail if neither is available, and use `setFlagEnv` to make the resolved credential available to runner scripts as `PUSH_TOKEN`. Coordinate this with Forgejo support in the agents repository, covering both the code and fix harnesses.
ⓘ 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. |
Watch note (ForgeOps)This PR was auto-closed by the vouch gate for first-time contributor Next (human): open a Vouch Request in your own words, then reopen this PR or open a fresh one after Qodo High triage (will address after vouch, before re-requesting review):
Medium items remain queued after the Highs. |
Summary
internal/forge/forgejoimplementingforge.Clientfor Forgejo/Gitea API v1DetectForge, harness validation, and repos forge enumTest plan
go test ./internal/forge/forgejo/ ./internal/forge/ -count=1go test ./internal/harness/ -run TestValidateForgego test ./internal/cli/ -run TestNewForgeClient_ForgejoMade with Cursor