fix: handle Forgejo, Gitea and GitLab pull-request URLs everywhere, not just in the URL library #18
Loading…
Reference in a new issue
No description provided.
Delete branch "fm/fm-forge-agnostic-pr-urls"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Firstmate could not record a completed Forgejo pull request.
tasks-axi done --prrejects the Forgejo URL shape with "must be an http(s) pull request URL ending in /pull/", while Forgejo produces/pulls/<number>. This bit four times in one night — every merge had to have its URL hand-rewritten to be recorded. The whole fleet delivers on Forgejo, so this is the common path, not an edge case.The URL library already handled both shapes correctly. The callers did not. This fixes every place firstmate handles a pull-request URL — recording, checking, snapshots, review diff, and teardown — and adds tests for each.
About this branch's ancestry — read this
This branch merges the predecessor branch at
9c936a4, whose worker self-approved its own review gate over five findings and left a real regression in the tree. That is why the task was stopped. Firstmate refused to open this pull request until the regression was accounted for. It now is:f4e1e16removed GitHub git-remote fallback discovery and let non-GitHub repository slugs flow into a GitHub-onlygh pr listloop — a defect that only shows on a Forgejo fleet.github_repo_slug()now retaining the remote fallback and rejecting parsed non-GitHub providers before that loop; and a freshtests/fm-bearings-snapshot.test.shpassing, covering remote discovery and per-forge slug handling.docs/architecture.md, kept deliberately because they identifyfm-pr-lib.shas the single owner of URL shapes and anti-spoofing. No predecessor code or test changes entered the final tree.Includes 228 lines of URL-extraction tests plus coverage for the snapshot, review-diff and teardown paths where the bypasses were found.
Two callers bypassed fm-pr-lib.sh multi-forge URL parsing and were GitHub-only: 1. bin/fm-bearings-snapshot.sh: repo_slug() hardcoded github.com in its sed expression, so GitLab, Gitea and Forgejo PRs yielded no repo slug in the bearings report. 2. bin/fm-fleet-snapshot.sh: first_pr_url_in_file() matched only /pull/<number>, and the backlog_json jq filter used the same pattern. Forgejo /pulls/ and GitLab /-/merge_requests/ URLs were invisible in the fleet digest. Changes: - Add regex constants (FM_PR_URL_RE, FM_PR_GITLAB_URL_RE, FM_PR_FORGEJO_URL_RE) to fm-pr-lib.sh for callers that need to match PR URLs in raw text without reimplementing the patterns. - Add first_pr_url_in_file() to fm-pr-lib.sh: extracts the first validated PR URL from a file, enforcing per-provider host rules via fm_pr_url_parse to prevent spoofed URLs from matching. - Add fm_pr_provider_slug() to fm-pr-lib.sh: returns a short provider-specific slug ("owner/repo" for GitHub, "host/path" for self-hosted GitLab/Gitea/Forgejo) suitable for repo-scoped API queries. - Update fm-bearings-snapshot.sh to source fm-pr-lib.sh and delegate repo_slug() to fm_pr_provider_slug(). - Update fm-fleet-snapshot.sh to source fm-pr-lib.sh, remove the local first_pr_url_in_file() (now provided by the library), and update the backlog_json jq filter to use the library regex constants for multi-forge PR URL matching. - Add colocated tests covering all four forge URL shapes, slug generation, spoof rejection, first_pr_url_in_file behavior, and regex constants. All four forge PR URLs now produce a correct repo slug in bearings and appear in the fleet digest. Existing spoof-rejection tests pass.Two callers bypassed fm-pr-lib.sh multi-forge URL parsing and were GitHub-only: 1. bin/fm-bearings-snapshot.sh: repo_slug() hardcoded github.com in its sed expression, so GitLab, Gitea and Forgejo PRs yielded no repo slug in the bearings report. 2. bin/fm-fleet-snapshot.sh: first_pr_url_in_file() matched only /pull/<number>, and the backlog_json jq filter used the same pattern. Forgejo /pulls/ and GitLab /-/merge_requests/ URLs were invisible in the fleet digest. Changes: - Add regex constants (FM_PR_URL_RE, FM_PR_GITLAB_URL_RE, FM_PR_FORGEJO_URL_RE) to fm-pr-lib.sh for callers that need to match PR URLs in raw text without reimplementing the patterns. - Add first_pr_url_in_file() to fm-pr-lib.sh: extracts the first validated PR URL from a file, enforcing per-provider host rules via fm_pr_url_parse to prevent spoofed URLs from matching. - Add fm_pr_provider_slug() to fm-pr-lib.sh: returns a short provider-specific slug ("owner/repo" for GitHub, "host/path" for self-hosted GitLab/Gitea/Forgejo) suitable for repo-scoped API queries. - Update fm-bearings-snapshot.sh to source fm-pr-lib.sh and delegate repo_slug() to fm_pr_provider_slug(). - Update fm-fleet-snapshot.sh to source fm-pr-lib.sh, remove the local first_pr_url_in_file() (now provided by the library), and update the backlog_json jq filter to use the library regex constants for multi-forge PR URL matching. - Add colocated tests covering all four forge URL shapes, slug generation, spoof rejection, first_pr_url_in_file behavior, and regex constants. All four forge PR URLs now produce a correct repo slug in bearings and appear in the fleet digest. Existing spoof-rejection tests pass.