trunkjet

Builds and dependencies

On this page

Mirrors and vendoring

Use third-party code without leaving trunkjet: the server keeps a live read-only mirror of an upstream GitHub or GitLab repository, and tjet vendor copies a mirrored version into a folder of your repository as an ordinary, reviewable change that you can patch and later update.

Mirrors

A mirror is named by its source key, host/owner/repo (for example github.com/rust-lang/log; GitLab subgroups are allowed: gitlab.com/group/sub/project). The server derives the upstream URL from that key; you never give it a URL.

tjet mirror add github.com/rust-lang/log            # tenant_admin: a private mirror of your organization
tjet mirror add github.com/acme/secret-lib --credential gh-acme   # private upstream (server-side credential)
tjet mirror add github.com/rust-lang/log --public   # operator tenant only: shared with every organization
tjet mirror show github.com/rust-lang/log           # branch, head commit, last sync, failures, next attempt
tjet mirror sync github.com/rust-lang/log           # ask for a sync soon (rate-limited)
tjet mirror list
  • Read-only. A mirror is a normal repository that only its sync writes. It cannot be made writable; to change the code, vendor it.
  • Who can read. A public mirror: everyone signed in to the installation (reader role only). A private mirror: like any repository, the people and groups with a binding (tjet repo grant), plus the organization's administrators; the administrator who registered it is its repository administrator. Agents and scoped tokens read it only through a binding of their own and never beyond their sponsor. To anyone else a private mirror looks exactly like no mirror.
  • Freshness. The worker syncs every 15 minutes by default; after a failure it retries after 1 minute, doubling up to 6 hours. A refusal that retrying cannot fix (over a limit, unknown branch, missing credential) pauses the mirror until tjet mirror sync asks again. tjet mirror sync asks for a sync now.
  • What a mirror follows. One branch (the upstream default unless --branch) and all tags. If upstream rewrites the branch (force push), the mirror follows; older commits stay readable, so folders vendored from them can still be updated.
  • Incremental. A sync converts only the commits that are new since the previous sync; an unchanged upstream costs one fetch and nothing else. Every sync's record of the original Git objects is kept, so a Git export of the mirror reproduces all upstream commit ids.
  • Untrusted content. Nothing from the upstream runs: no hooks, filters, submodules or Git LFS downloads. Invalid paths and submodules are left out, LFS pointers stay pointer files; each such change is listed in the import report. Repositories over the size, object-count or time limits are refused.

Vendoring

tjet vendor add github.com/rust-lang/[email protected] third_party/log   # REF: branch, tag or full commit id
tjet save -m "Vendor log 0.4.22"                                  # then review and land as usual
tjet vendor status                                                # local patches; is upstream newer?
tjet vendor update third_party/log --ref 0.4.25                   # three-way merge, local patches kept

vendor add writes the files into a new folder, tracks them in your current change, and records the origin in third_party/log/.tjet-vendor.json: source, requested ref, upstream commit, mirror revision, detected licences (MIT, Apache-2.0, BSD-3-Clause, ... or unknown) with their licence files, and the SHA-256 of every vendored file.

vendor update compares three states of every file: the recorded upstream version (base), the folder now (yours) and the new upstream version (theirs).

Changed inResult
upstream onlyupstream version taken (added, replaced or deleted)
your folder onlyyour version kept
both, textmerged; overlapping edits get <<<<<<< / `
both, other (binary, deleted, link)your version kept and reported

With any conflict the command exits with code 4 (MERGE_CONFLICT) and lists the files; resolve them, then save. Without --ref an update follows the ref recorded at add (a branch moves, a tag or commit id stays put).

Vendored copies deduplicate within your repository; each mirror is its own deduplication domain, so a vendored copy is uploaded once per repository and never reveals anything about other repositories' content. (Sharing the stored bytes between a mirror and the repositories that vendor it needs reference counting across repositories in the store; see D-1780.)

Server configuration

VariableMeaning (default)
TJET_MIRROR_DIRFetch cache, one bare repository per mirror. Mirrors are off without it.
TJET_MIRROR_HOSTShost=base-url,... (github.com=https://github.com,gitlab.com=https://gitlab.com)
TJET_MIRROR_PROTOCOLSAllowed URL schemes (https; http/git only for tests or private networks)
TJET_MIRROR_CREDENTIALSCredential file, mode 0600: lines <tenant-uuid>/<name> <Authorization header value>
TJET_MIRROR_PUBLIC_TENANTUUID of the operator tenant whose administrators register public mirrors
TJET_MIRROR_INTERVAL_S / TJET_MIRROR_ON_DEMAND_SSync interval (900) / minimum gap between on-demand syncs (60)
TJET_MIRROR_FETCH_TIMEOUT_SWall-clock limit of one fetch (3600)
TJET_MIRROR_MAX_BYTES / TJET_MIRROR_MAX_OBJECTSFetched repository limits (20 GiB / 50 million objects)
TJET_MIRROR_CONCURRENCYSyncs at once per worker process (2)
TJET_MIRROR_MAX_PER_TENANTMirrors one organization (or the public scope) may register (200)

Set them for tjetd (with --with-worker) and every tjet-worker. A credential is read at sync time, sent only over HTTPS, and never stored in FoundationDB, returned or logged. For a GitHub token use Basic <base64 of x-access-token:TOKEN> or Bearer TOKEN.

Metrics: tjet_mirror_syncs_total{outcome="unchanged|updated|failed"}, tjet_worker_duty_failures_total{duty="mirrors"}.

Limits

  • One branch per mirror.
  • A vendored copy is stored again in each repository that vendors it.
  • Public mirrors are registered by the operator; automatic creation on first use is not offered yet.
  • Credentials are static header values (a GitHub/GitLab App token exchange is not built in).