Add Forgejo support alongside GitHub for PR checks #1

Open
eddie wants to merge 3 commits from forgejo-support into main
Owner

prch can now read PRs and CI checks from Forgejo as well as GitHub. It picks the forge from the origin remote's host.

main.go

  • Replaced repoFromGit with forgeFromGit and parseRemote. These read the origin URL with git remote get-url and support ssh, scp-style, and https remotes on any host.
  • Added a forge struct that holds the API base, web base, token, owner, and repo. github.com uses the GitHub API. Every other host uses https://<host>/api/v1.
  • Added forgejoToken. It checks FORGEJO_TOKEN, then GITEA_TOKEN, then the token that fj auth login saved in forgejo-cli/keys.json.
  • Replaced ghGet with forge.get and the shared repoPath helper. All fetch functions now take a forge instead of token/owner/repo.
  • Commit statuses now come from the combined /status endpoint, which already returns only the newest status per context, so dedupeStatuses is removed.
  • Check runs are fetched only on GitHub. On Forgejo, Actions jobs come from commit statuses.
  • Forgejo differences:
    • Reads the status from the status field.
    • Turns site-relative target URLs into full URLs.
    • Counts REQUEST_CHANGES as a changes-requested review.
  • Added the limit query param to list endpoints to set Forgejo's page size.

README.md

  • Updated the description, requirements, and usage sections for Forgejo, including the token lookup order and how the host decides which API is used.
prch can now read PRs and CI checks from Forgejo as well as GitHub. It picks the forge from the `origin` remote's host. **main.go** - Replaced `repoFromGit` with `forgeFromGit` and `parseRemote`. These read the origin URL with `git remote get-url` and support ssh, scp-style, and https remotes on any host. - Added a `forge` struct that holds the API base, web base, token, owner, and repo. `github.com` uses the GitHub API. Every other host uses `https://<host>/api/v1`. - Added `forgejoToken`. It checks `FORGEJO_TOKEN`, then `GITEA_TOKEN`, then the token that `fj auth login` saved in `forgejo-cli/keys.json`. - Replaced `ghGet` with `forge.get` and the shared `repoPath` helper. All fetch functions now take a `forge` instead of token/owner/repo. - Commit statuses now come from the combined `/status` endpoint, which already returns only the newest status per context, so `dedupeStatuses` is removed. - Check runs are fetched only on GitHub. On Forgejo, Actions jobs come from commit statuses. - Forgejo differences: - Reads the status from the `status` field. - Turns site-relative target URLs into full URLs. - Counts `REQUEST_CHANGES` as a changes-requested review. - Added the `limit` query param to list endpoints to set Forgejo's page size. **README.md** - Updated the description, requirements, and usage sections for Forgejo, including the token lookup order and how the host decides which API is used.
add workflows, update versioning method
Some checks failed
lint / golangci-lint (pull_request) Failing after 1m53s
4c6acf4d25
lint updates
All checks were successful
lint / golangci-lint (pull_request) Successful in 27s
832de436ea
All checks were successful
lint / golangci-lint (pull_request) Successful in 27s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin forgejo-support:forgejo-support
git switch forgejo-support

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff forgejo-support
git switch forgejo-support
git rebase main
git switch main
git merge --ff-only forgejo-support
git switch forgejo-support
git rebase main
git switch main
git merge --no-ff forgejo-support
git switch main
git merge --squash forgejo-support
git switch main
git merge --ff-only forgejo-support
git switch main
git merge forgejo-support
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
eddie/prch!1
No description provided.