implement Forgejo as another server variant #43

Closed
opened 2026-07-31 18:28:07 +00:00 by hugo · 2 comments
Owner

the server adding screen needs to get a dropdown with API providers. the first two API providers will be:

  • gitea (the current code and the default)
  • forgejo

the backend crate needs to be refactored to have different backend handlings for the generated API code, so that different servers can be added to the app. the core API code then handles the differences, where there are any.

the gotcha CLI tool and the iPhone app seamlessly support both backends, so that a user does not need to know if they are working on gitea or forgejo servers, outside of setting up the connection.

Optimal would be a discovery through the API, so that the user doesn't even have to select the API mode at all. Also try to keep differences small, so that at best we stick to the common subset where possible.

the server adding screen needs to get a dropdown with API providers. the first two API providers will be: - gitea (the current code and the default) - forgejo the backend crate needs to be refactored to have different backend handlings for the generated API code, so that different servers can be added to the app. the core API code then handles the differences, where there are any. the gotcha CLI tool and the iPhone app seamlessly support both backends, so that a user does not need to know if they are working on gitea or forgejo servers, outside of setting up the connection. Optimal would be a discovery through the API, so that the user doesn't even have to select the API mode at all. Also try to keep differences small, so that at best we stick to the common subset where possible.
hugo added this to the first public update release milestone 2026-07-31 18:28:07 +00:00
hugo added the enhancement label 2026-07-31 18:28:07 +00:00
hugo modified the milestone from first public update release to first feature complete release 2026-08-03 08:22:19 +00:00
Author
Owner

Implemented and verified in d47b21d.

  • Added a persisted gitea/forgejo provider model shared by the Rust API client, CLI configuration, and app preferences. Existing configurations migrate to Gitea by default.
  • Added provider discovery through the common version API and Forgejo's dedicated API, including modern Forgejo version-marker detection. Shared operations continue through the common typed /api/v1 client; provider-specific version handling stays inside gotcha_gitea.
  • Extended gotcha auth login with optional --provider gitea|forgejo, automatic discovery, provider-aware status/list output, and provider-aware client construction.
  • Added a native single-selection provider menu to Add Server on iOS, with Gitea selected by default, Forgejo-specific URL guidance, Dynamic Type, and an explicit VoiceOver value.
  • Regenerated and committed the UniFFI Swift/C bridge, and updated README, API coverage, and TESTING.md.

Verification:

  • cargo fmt --all -- --check
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (32 tests passed)
  • Live typed Forgejo reads against Codeberg: server version and forgejo/forgejo repository lookup succeeded.
  • iPhone 17 Pro Simulator: generated, built, installed, launched, and visually checked Add Server. Confirmed the native menu, Gitea default, Forgejo selection, changing URL example, and VoiceOver provider value.
  • Paired iPhone device build: signed Debug device build succeeded.
Implemented and verified in `d47b21d`. - Added a persisted `gitea`/`forgejo` provider model shared by the Rust API client, CLI configuration, and app preferences. Existing configurations migrate to Gitea by default. - Added provider discovery through the common version API and Forgejo's dedicated API, including modern Forgejo version-marker detection. Shared operations continue through the common typed `/api/v1` client; provider-specific version handling stays inside `gotcha_gitea`. - Extended `gotcha auth login` with optional `--provider gitea|forgejo`, automatic discovery, provider-aware status/list output, and provider-aware client construction. - Added a native single-selection provider menu to Add Server on iOS, with Gitea selected by default, Forgejo-specific URL guidance, Dynamic Type, and an explicit VoiceOver value. - Regenerated and committed the UniFFI Swift/C bridge, and updated README, API coverage, and `TESTING.md`. Verification: - `cargo fmt --all -- --check` - `RUSTFLAGS="-D warnings" cargo check --workspace --all-targets` - `cargo clippy --workspace --all-targets -- -D warnings` - `cargo test --workspace` (32 tests passed) - Live typed Forgejo reads against Codeberg: server version and `forgejo/forgejo` repository lookup succeeded. - iPhone 17 Pro Simulator: generated, built, installed, launched, and visually checked Add Server. Confirmed the native menu, Gitea default, Forgejo selection, changing URL example, and VoiceOver provider value. - Paired iPhone device build: signed Debug device build succeeded.
hugo closed this issue 2026-08-03 16:15:17 +00:00
hugo reopened this issue 2026-08-03 16:28:48 +00:00
Author
Owner

Compatibility correction implemented and verified in 7376e6c.

The original implementation incorrectly assumed that every operation in Gotcha's generated Gitea 1.25.2 client was available through Forgejo's Gitea-compatible API. Forgejo advertises compatibility with Gitea 1.22, and nested repository browsing used the newer GET /repos/{owner}/{repo}/contents-ext/{filepath} operation. That endpoint is absent from Gitea 1.22 and returned 404 on Codeberg.

The correction replaces it with the shared Gitea 1.22 GET /repos/{owner}/{repo}/contents/{filepath} operation and decodes the directory array returned by both Gitea and Forgejo. A local HTTP test verifies the exact compatible path, nested-path encoding, and response decoding.

Contract review:

  • Audited every generated operation called by Gotcha against official Gitea 1.22.6: all 40 remaining operations exist.
  • Audited those operations against Codeberg's live Forgejo 16.0.0-dev-668-1bdb1938+gitea-1.22.0 OpenAPI contract: all 40 exist.
  • Compared all 38 reachable response definitions: no missing definitions, required fields, incompatible shared shapes, or unknown Forgejo enum values.
  • Confirmed Codeberg's compatible nested contents endpoint returns the expected array; the removed contents-ext endpoint returns 404.

Verification:

  • cargo fmt --all -- --check
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (33 tests passed)
  • iPhone 17 Pro Simulator build succeeded.
  • Signed paired-iPhone build succeeded.
Compatibility correction implemented and verified in `7376e6c`. The original implementation incorrectly assumed that every operation in Gotcha's generated Gitea 1.25.2 client was available through Forgejo's Gitea-compatible API. Forgejo advertises compatibility with Gitea 1.22, and nested repository browsing used the newer `GET /repos/{owner}/{repo}/contents-ext/{filepath}` operation. That endpoint is absent from Gitea 1.22 and returned 404 on Codeberg. The correction replaces it with the shared Gitea 1.22 `GET /repos/{owner}/{repo}/contents/{filepath}` operation and decodes the directory array returned by both Gitea and Forgejo. A local HTTP test verifies the exact compatible path, nested-path encoding, and response decoding. Contract review: - Audited every generated operation called by Gotcha against official Gitea 1.22.6: all 40 remaining operations exist. - Audited those operations against Codeberg's live Forgejo `16.0.0-dev-668-1bdb1938+gitea-1.22.0` OpenAPI contract: all 40 exist. - Compared all 38 reachable response definitions: no missing definitions, required fields, incompatible shared shapes, or unknown Forgejo enum values. - Confirmed Codeberg's compatible nested contents endpoint returns the expected array; the removed `contents-ext` endpoint returns 404. Verification: - `cargo fmt --all -- --check` - `RUSTFLAGS="-D warnings" cargo check --workspace --all-targets` - `cargo clippy --workspace --all-targets -- -D warnings` - `cargo test --workspace` (33 tests passed) - iPhone 17 Pro Simulator build succeeded. - Signed paired-iPhone build succeeded.
hugo closed this issue 2026-08-03 16:29:50 +00:00
Sign in to join this conversation.