Skip to content

Latest commit

Β 

History

History
118 lines (89 loc) Β· 6.26 KB

gitflic.md

File metadata and controls

118 lines (89 loc) Β· 6.26 KB

gitflic.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--.

GitFlic adapter (gitflic.ru, API api.gitflic.ru; a self-hosted instance answers under <host>/rest-api). GitFlic has its own API and is not Gitea-compatible. 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 GitFlic.

The defining constraint: GitFlic has no get-by-tag endpoint.

  • A release lookup pages through GET /project/{o}/{p}/release?page=N&size=S (pages are zero-based) and matches tagName itself, reading _embedded.releaseTagModelList[] with page.totalPages / page.number.
  • A tag lookup pages through GET .../tag?page&size reading _embedded.tagList[] and matching name, because GET .../tag/{name} answered 400 in the probe.

Because the forge rate-limits (gitflic.ru allows roughly 500 requests per hour), paging is bounded: FORGE_GITFLIC_MAX_PAGES (default 20) pages of 50 items. Reaching the cap without a match is reported as GAP readback_page_cap β€” never "absent" β€” because "not found in what we were willing to read" and "not there" are different facts, and conflating them is exactly the fail-open shape the constitution forbids.

FG_TARGET_DERIVED=0: whether GitFlic's commitId is derived from the tag is UNCONFIRMED / not live-proven, so it is not trusted. FG_PRE_SUPPORTED=1 (the list carries preRelease).

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.

Optional env var: FORGE_GITFLIC_MAX_PAGES (default 20; must match ^[0-9]{1,3}$ and be at least 1, otherwise it falls back to 20).

Usage examples

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

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

# widen the bounded paging when the release lives deeper in the list
FORGE_GITFLIC_MAX_PAGES=40 bash scripts/forge/forge.sh release-get \
  --url git@gitflic.ru:org/repo.git --tag v1.0.0

Contract check in isolation:

bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitflic.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"'

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. When _gitflic_find cannot decide within its page budget it sets _GF_FOUND=cap, which surfaces as GAP readback_page_cap (exit 3 through forge.sh). User-visible exit codes belong to forge.sh β€” see docs/scripts/forge.md.

Edge cases

  • Page cap reached without a match β€” FG_REL_STATE=gap with readback_page_cap for a release, and FG_TAG_STATE=unknown for a tag. Deliberately not absent: the list was not read to its end.
  • A non-200 from the list mid-paging β€” _gitflic_find returns 0 with _GF_FOUND left at error, so the caller reports an unexpected status rather than inventing an answer.
  • page.totalPages missing or non-numeric β€” the loop stops with error rather than looping forever.
  • A jq failure while extracting the match β€” returns 0 without setting _GF_FOUND=1, so a parse problem is never upgraded into a found release.
  • FORGE_GITFLIC_MAX_PAGES invalid β€” silently normalised to 20 (documented bound, not a crash).
  • No draft concept β€” FG_REL_DRAFT is false, not unknown.
  • No get-by-tag β€” a tag lookup measures cost in requests; raising the page cap raises the request count against a 500/hour budget.
  • Write paths (POST .../release, PUT .../release/{id}) are LIVE-UNPROVEN.

Internal behaviour

  1. GITFLIC_SIZE=50 β€” page size, a file-level constant.
  2. prov_init β€” Authorization: token %s, Accept: application/json, FG_RPATH="/project/$FG_OWNER/$FG_REPO", FG_PRE_SUPPORTED=1, FG_TARGET_DERIVED=0.
  3. _gitflic_max_pages validates FORGE_GITFLIC_MAX_PAGES and prints the effective page budget.
  4. _gitflic_find KIND TAG walks pages from 0: for kind=release it reads _embedded.releaseTagModelList matching tagName; for kind=tag it reads _embedded.tagList matching name. A single jq counts matches; on a hit the best match is written to $FG_TMP/page.json. It stops on p >= page.totalPages, otherwise _GF_FOUND=cap when the budget is exhausted.
  5. prov_release_get maps _GF_FOUND 1/0/cap to present/absent/gap, extracting id, tagName, preRelease, commitId from page.json.
  6. prov_release_create builds {title,description,tagName,preRelease,attachProjectArchive:false} and POSTs; 200|201 β†’ created, 409 β†’ exists.
  7. prov_release_update PUTs {title,description,tagName,preRelease} to /release/{id}; 200 β†’ updated.
  8. prov_tag_get reuses _gitflic_find tag, mapping 1/0/cap to present/absent/unknown and taking commitId as the sha.
  9. prov_probe GETs the project and one-item slices of the release and tag lists.

Related scripts

  • scripts/forge/providers/gitea.sh β€” the canonical provider-contract statement this file implements.
  • scripts/forge/forge.sh β€” the driver; turns cap into GAP readback_page_cap.
  • scripts/forge/lib/http.sh β€” the HTTP client.
  • config/forge/hosts.tsv β€” maps gitflic.ru to gitflic with token variable GITFLIC_TOKEN, and records that the release lookup pages through the list.

Last verified

2026-12-04 β€” bash -n scripts/forge/providers/gitflic.sh β†’ exit 0. Contract check a reader can repeat:

bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitflic.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: token %s|/project/o/r|1|0.