Revision: 1 Last modified: 2026-12-04T18:15:21Z
This is a library. It is sourced by scripts/forge/forge.sh, never executed. No shebang, mode
rw-rw-r--.
GitLab adapter — GitLab REST v4 over curl. 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
GitLab, and GitLab is the most behaviourally different of the five.
Two properties matter:
- GitLab has no pre-release flag.
FG_PRE_SUPPORTED=0, soforge.shprintsNOTE: prerelease_unsupportedand never claims a prerelease there. Asking for--prereleasedoes not fail; it is honestly downgraded and reported. - GitLab is the one forge whose release target is DERIVED from the tag.
FG_TARGET_DERIVED=1: the release object'scommit.idis the commit the forge resolves from the tag, not a field the tool sent. That is the only case in this tool where a read-back target can contribute to proving the commit, which makes GitLab the one provider whererelease-ensurecan reachRESULT: OKon a release that already existed without a separate tag check.
Also: a project is addressed by its URL-encoded full path — group/sub/project becomes
group%2Fsub%2Fproject — and forge.sh deliberately allows GitLab paths deeper than OWNER/REPO (up to 20
segments) for exactly this reason. A release is addressed by its tag, not by a numeric id.
As for every provider: sourced by forge.sh after lib/common.sh / lib/credentials.sh / lib/http.sh, with
FG_OWNER, FG_REPO, FG_REPO_FULL, FG_API_BASE, FG_API_ORIGIN and an initialised FG_TMP. Needs jq.
Through forge.sh (this file is not invoked directly):
bash scripts/forge/forge.sh detect --remote origin
bash scripts/forge/forge.sh probe --remote origin
bash scripts/forge/forge.sh tag-get --remote origin --tag v1.2.3
# a nested group path is legal on GitLab only
bash scripts/forge/forge.sh repo-exists --url git@gitlab.com:group/sub/project.gitContract check in isolation:
bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitlab.sh; \
FG_OWNER=g FG_REPO=p FG_REPO_FULL=group/sub/project; prov_init; \
printf "%s|%s|%s|%s\n" "$FG_AUTH_FMT" "$FG_RPATH" "$FG_PRE_SUPPORTED" "$FG_TARGET_DERIVED"'Library: functions return 0 when a state was determined and 1 only when no HTTP answer arrived
(FG_NET set). Every HTTP status is a result encoded in the state variables. User-visible exit codes belong to
forge.sh — see docs/scripts/forge.md.
--prereleaserequested — accepted but not applied;forge.shprintsNOTE: prerelease_unsupported. No false claim, no hard failure.- A draft release — GitLab has no draft concept here, so
FG_REL_DRAFTis pinned tofalserather than leftunknown; a caller can therefore read it without a "did the forge report this" caveat. - A release id —
FG_REL_IDis set to the tag name, because GitLab addresses a release by tag. The id-safety check inforge.sh(fg_ok_rel_id) therefore accepts a tag-shaped id for GitLab and a numeric/UUID id for the other four. - A nested project path — encoded, never resolved by hand.
forge.shrefuses path segments that are unsafe, and refuses paths deeper than 20 segments. - An annotated tag —
repository/tags/{tag}reportscommit.id, which is already the commit the tag resolves to; no peel is needed. - Write paths (
POST /releases,PUT /releases/{tag}) are LIVE-UNPROVEN. Note the update verb isPUThere, notPATCH. scripts/release/tag_and_release.shkeeps its ownglableg — a separate path by design decision, not a duplicate of this adapter.
prov_init—PRIVATE-TOKEN: %s,Accept: application/json,FG_RPATH="/projects/${FG_REPO_FULL//\//%2F}",FG_PRE_SUPPORTED=0,FG_TARGET_DERIVED=1.prov_repoGETs the project and setsFG_HAS_RELEASES=unknown(GitLab does not expose a unit flag this adapter reads).prov_release_getGETs/releases/{tag};200→presentwithtag_name,FG_REL_ID="$FG_REL_TAG"andcommit.idas the target;404→absent. There is noreleases_disabledgap here.prov_release_createbuilds{tag_name,name,description}(descriptionfrom the notes file via--rawfile) and POSTs;201→created,409→exists. ThePREargument is ignored on purpose.prov_release_updatePUTs{name,description}to/releases/{tag};200→updated.prov_tag_getGETs/repository/tags/{tag};200→presentwith.commit.id,404→absent.prov_probeissues three read-only GETs: project,/releases?per_page=1,/repository/tags?per_page=1.
scripts/forge/providers/gitea.sh— the canonical provider-contract statement this file implements.scripts/forge/forge.sh— the driver; note the GitLab special case infg_ok_rel_idand theFG_TARGET_DERIVED=1path infg_end_ensure.scripts/forge/lib/http.sh— the HTTP client.scripts/release/tag_and_release.sh— theglab-based sibling leg.config/forge/hosts.tsv— mapsgitlab.comtogitlabwith token variableGITLAB_TOKEN, and records that GitLab has no pre-release flag.
2026-12-04 — bash -n scripts/forge/providers/gitlab.sh → exit 0. Contract check a reader can repeat:
bash -c '. scripts/forge/lib/common.sh; . scripts/forge/providers/gitlab.sh; \
FG_OWNER=g FG_REPO=p FG_REPO_FULL=group/sub/project; prov_init; \
printf "%s|%s|%s|%s\n" "$FG_AUTH_FMT" "$FG_RPATH" "$FG_PRE_SUPPORTED" "$FG_TARGET_DERIVED"'Expected: PRIVATE-TOKEN: %s|/projects/group%2Fsub%2Fproject|0|1.