Skip to content

Latest commit

 

History

History
125 lines (97 loc) · 7.05 KB

gitverse.md

File metadata and controls

125 lines (97 loc) · 7.05 KB

gitverse.md (scripts/forge/providers)

Revision: 1 Last modified: 2026-12-04T18:15:21Z

Overview

This is a library. It is sourced by scripts/forge/forge.sh, never executed. No shebang, mode rw-rw-r--.

GitVerse adapter (gitverse.ru, API api.gitverse.ru) — a GitHub-shaped own API. It implements the same provider contract as scripts/forge/providers/gitea.sh; read that guide for the contract. This guide records what is specific to GitVerse, which is the most anomalous of the five and the reason two opt-in flags exist.

Three facts drive the design:

  1. A mandatory Accept header. Accept: application/vnd.gitverse.object+json;version=1 — without it the API answers 415. Auth is Authorization: Bearer.
  2. The release list is unreliable in a very specific way. GET /repos/{o}/{r}/releases answers 404 {"code":"REPO_NOT_FOUND"} for a repository that GET /repos/{o}/{r} answers 200, and /releases/tags/{tag} also answers 404. That state cannot be told apart from "no release yet" or "releases unsupported", so it is the GAP releases_unsupported_or_empty — never absent, never success. This is why forge.sh release-ensure has the explicit opt-in --try-create-on-ambiguous: on this forge the create is attempted and then only the read-back decides.
  3. Tag endpoints are partly broken. git/matching-refs/tags/{tag} works; git/tags/{sha} and /tags answer 400 (live 2026-11-12). An annotated tag is peeled through commits/{tag-object-sha} (live 2026-11-16), which answers 200 with the commit the forge peels from the tag. Asked by the tag-object sha, never by the tag name, because a branch of the same name could shadow it.

FG_TARGET_DERIVED=0 — GitHub-shaped, so target_commitish is the stored request field. FG_PRE_SUPPORTED=1, but the prerelease field is not documented; when the read-back does not report it, forge.sh prints NOTE: prerelease_unverified rather than assuming.

Prerequisites

As for every provider: sourced by forge.sh after lib/common.sh / lib/credentials.sh / lib/http.sh, with FG_OWNER, FG_REPO, FG_API_BASE, FG_API_ORIGIN and an initialised FG_TMP. Needs jq.

Usage examples

Through forge.sh (this file is not invoked directly):

bash scripts/forge/forge.sh detect --url git@gitverse.ru:org/repo.git
bash scripts/forge/forge.sh probe  --url git@gitverse.ru:org/repo.git
bash scripts/forge/forge.sh tag-get --url git@gitverse.ru:org/repo.git --tag v1.0.0

# the release list is ambiguous here; without the opt-in this is a GAP
bash scripts/forge/forge.sh release-get --url git@gitverse.ru:org/repo.git --tag v1.0.0

# opt in: try the create, and let the read-back decide
bash scripts/forge/forge.sh release-ensure --url git@gitverse.ru:org/repo.git --tag v1.0.0 \
  --sha <sha40> --notes-file notes.md --try-create-on-ambiguous

Contract check in isolation:

bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitverse.sh; FG_OWNER=o FG_REPO=r; prov_init; \
  printf "%s|%s|%s|%s|%s\n" "$FG_AUTH_FMT" "$FG_HDRS" "$FG_RPATH" "$FG_PRE_SUPPORTED" "$FG_TARGET_DERIVED"'

Exit codes

Library: functions return 0 when a state was determined and 1 only when no HTTP answer arrived (FG_NET set). HTTP statuses are results encoded in state. A 404 on the release list surfaces as GAP releases_unsupported_or_empty (exit 3 through forge.sh). User-visible exit codes belong to forge.sh — see docs/scripts/forge.md.

Edge cases

  • 404 on /releases/tags/{tag} — this file does not immediately call it absent. It re-checks the release list: 200 on the list → absent (releases work, there is simply none of this tag); 404 on the list → gap / releases_unsupported_or_empty. That second check is the whole point.
  • Anything other than 200/404 on the release-by-tag lookup — returns 0 with FG_REL_STATE left error, so the caller reports an unexpected status instead of guessing.
  • Create returns 403 or 404 — FG_CREATE=refused, which forge.sh turns into GAP releases_unsupported_or_empty under --try-create-on-ambiguous ("the create was refused: releases look unsupported here").
  • 409 or 422 on create — FG_CREATE=exists, so forge.sh reads the existing release back and compares rather than creating a duplicate.
  • An annotated tag — git/tags/{sha} answers 400; the fallback is commits/{tag-object-sha}. Only a full commit id that is not the tag-object sha itself counts; anything else yields TAG: present sha=unknown (commit unverified), never a fabricated commit.
  • A branch named like the tag — cannot shadow the result, because the peel is asked by tag-object sha.
  • The prerelease flag missing from the read-back — NOTE: prerelease_unverified.
  • Write paths (POST /releases, PATCH /releases/{id}) are LIVE-UNPROVEN.

Internal behaviour

  1. prov_init — Authorization: Bearer %s; header Accept: application/vnd.gitverse.object+json;version=1; FG_RPATH="/repos/$FG_OWNER/$FG_REPO"; FG_PRE_SUPPORTED=1; FG_TARGET_DERIVED=0.
  2. prov_release_get GETs /releases/tags/{tag}. 200 → present with id, tag_name, prerelease, draft, target_commitish. 404 falls through to the list check; any other status leaves error.
  3. The list check: GET /releases?per_page=1 → 200 means absent, 404 means gap / releases_unsupported_or_empty.
  4. prov_release_create builds {tag_name,target_commitish,name,body,draft:false,prerelease} and POSTs; 200|201 → created, 409|422 → exists, 403|404 → refused.
  5. prov_release_update PATCHes {name,body,prerelease} to /releases/{id}; 200 → updated.
  6. prov_tag_get GETs /git/matching-refs/tags/{tag}, selects the entry whose ref equals refs/tags/<tag>, then: if object.type == tag and the sha is full, GET /git/tags/{sha}; when that is not 200, GET /commits/{tag-object-sha} and accept its .sha only if it is a full commit id different from the tag-object sha. Finally FG_TAG_SHA is set only when the resolved type is commit.
  7. prov_probe GETs the repo, /releases?per_page=1, and /git/matching-refs/tags/.

Related scripts

  • scripts/forge/providers/gitea.sh — the canonical provider-contract statement this file implements.
  • scripts/forge/forge.sh — the driver; owns --try-create-on-ambiguous and the releases_unsupported_or_empty reporting.
  • scripts/forge/lib/http.sh — the HTTP client.
  • config/forge/hosts.tsv — maps gitverse.ru to gitverse with token variable GITVERSE_TOKEN, and records that the release list answers 404 (ambiguous).

Last verified

2026-12-04 — bash -n scripts/forge/providers/gitverse.sh → exit 0. Contract check a reader can repeat:

bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitverse.sh; FG_OWNER=o FG_REPO=r; prov_init; \
  printf "%s|%s|%s|%s\n" "$FG_AUTH_FMT" "$FG_RPATH" "$FG_PRE_SUPPORTED" "$FG_TARGET_DERIVED"'

Expected: Authorization: Bearer %s|/repos/o/r|1|0.