Skip to content

Add Tangled forge support - #120

Merged
andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feat/tangled-support
Jul 26, 2026
Merged

Add Tangled forge support#120
andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feat/tangled-support

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

closes #13

Summary

Adds initial Tangled.org support as a forge backend.

This includes:

  • new tangled forge type
  • Tangled detection via /xrpc/sh.tangled.knot.version
  • resolver, CLI, config and README wiring
  • TANGLED_TOKEN environment variable support
  • read-only Tangled adapter support for repository metadata, branches, tags and tree listing
  • tests for detection, resolver defaults, token lookup and Tangled XRPC behavior

Testing

env GOCACHE=/private/tmp/forge-gocache go test ./...
git diff --check

Note: Operations that cannot be safely represented by the current interfaces, especially issue/PR APIs that require numeric IDs, return ErrNotSupported.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial Tangled.org support as a new forge backend, integrating it into detection, resolution, configuration, and the CLI so the project can interact with Tangled repositories through the existing normalized interfaces.

Changes:

  • Introduce new tangled forge type and wire it into client registration, resolver defaults, CLI flags/help, and docs.
  • Add Tangled API detection via /xrpc/sh.tangled.knot.version plus TANGLED_TOKEN environment variable support.
  • Implement read-only Tangled adapter capabilities for repo metadata, branches, tags, and tree listing, with accompanying tests.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
types.go Adds the Tangled forge type constant.
detect.go Adds Tangled API probing via the XRPC version endpoint.
forge.go Extends ForgeBuilders and domain registration to support Tangled.
forges_test.go Adds detection test coverage for Tangled’s XRPC endpoint.
internal/resolve/resolve.go Wires Tangled into resolver builders, defaults, and forge-type dispatch.
internal/resolve/resolve_test.go Adds tests for Tangled token lookup and default domain mapping.
internal/config/config.go Updates config type documentation to include tangled.
internal/config/config_test.go Skips token-cmd execution tests on Windows (where unsupported).
internal/cli/root.go Updates CLI help text to include Tangled.
internal/cli/auth.go Adds Tangled to auth CLI help and known-domain env token checks.
internal/cli/repo_test.go Adds Tangled to forge-type → domain mapping tests.
README.md Documents Tangled support, builder registration, and TANGLED_TOKEN.
tangled/tangled.go Implements core Tangled forge client: XRPC helpers + HTML metadata parsing.
tangled/repos.go Implements Tangled repo metadata retrieval and tag listing.
tangled/branches.go Implements Tangled branch listing via XRPC.
tangled/files.go Implements Tangled tree listing via XRPC.
tangled/url.go Adds Tangled URL path parsing into ResourceRef.
tangled/unsupported.go Provides ErrNotSupported stubs for unsupported services.
tangled/tangled_test.go Adds tests for metadata parsing and XRPC-backed branches/tags/tree behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tangled/repos.go Outdated
Comment thread tangled/tangled.go Outdated

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the adapter follows the gitea/gerrit shape nicely and the Copilot fixes (DID reuse, io.LimitReader) look good.

A few things before merging:

Unrelated changes (same as #119):

  • internal/config/config_test.go adds Windows skips to TestLoadFileTokenCommand and TestLoadFileTokenCommandForgeDomain. Main runs both on Windows since #131 — please drop those 8 lines.
  • internal/cli/auth.go:87 adds "(Unix only)" to the --token-cmd help text; same #131 regression, please drop.
  • The branch now conflicts with main in exactly those two files, so rebasing will surface both.

Adapter:

  • tangled/branches.go:28 (and repos.go:81, files.go:30) — the XRPC repo param is set to just the owner DID; the repo name/rkey is never sent. parseRepoMeta matches at://<did>/sh.tangled.repo/<rkey> but only captures the DID. For an owner with more than one repo, which repo does listBranches?repo=<did> return? If the endpoint needs the rkey or repo name, repoDID should return/thread that through.
  • tangled/repos.go:41DefaultBranch is branches[0].Name from a Limit: 1 call. Nothing guarantees the first branch is the default; the entries carry a Default bool that isn't checked. Either scan for Default, or drop this and leave DefaultBranch empty for now.

Minor: WikiURL/ReleasesURL build /wiki and /releases paths Tangled doesn't have — returning repoHTMLURL would match what we did for Gerrit. Not blocking.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Done, thanks.

  • Dropped the unrelated Support token-cmd on Windows #131 regressions:
    • removed the Windows skips from both token-cmd tests
    • removed "(Unix only)" from the --token-cmd help text
  • Resolved the conflicts with main.
  • Updated Tangled XRPC calls to pass the full repository AT-URI (at://<did>/sh.tangled.repo/<rkey>) instead of only the owner DID.
  • Updated metadata parsing to capture the repo rkey.
  • Changed default branch detection to scan for the branch marked default instead of assuming the first branch is default.
  • Changed WikiURL and ReleasesURL to return the repository URL.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — all the earlier points are addressed and this merges cleanly with main. Two small things before merging:

  • tangled doesn't implement the APIBaseURLProvider interface that #141 just added, so forge api against a Tangled instance falls back to the legacy https://<domain>/api/v1 guess. Since Tangled speaks XRPC, returning f.baseURL + "/xrpc" from APIBaseURL() would make forge api sh.tangled.git.temp.listBranches work as expected.
  • RegisterDomain's new case Tangled calls builders.Tangled without a nil check, so an existing caller with a three-field ForgeBuilders literal would panic if probing detects a Tangled instance. Returning an error for a nil builder would fail more politely.

@andrew andrew mentioned this pull request Jul 23, 2026
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Done, thanks

  • Added APIBaseURL() for the Tangled backend, returning <base>/xrpc, so forge api sh.tangled.git.temp.listBranches uses the XRPC root.
  • Added a nil check for builders.Tangled in RegisterDomain, returning a clear error instead of panicking when older ForgeBuilders literals do not provide a Tangled builder.
  • Added regression tests for both changes.

@andrew
andrew merged commit 83cc189 into git-pkgs:main Jul 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Tangled.org support

3 participants