The tracker's labels are defined in the repository and a script creates or updates them on Forgejo #3

Closed
opened 2026-10-31 12:41:47 -04:00 by claude · 0 comments
Owner
  • Draft: PROC-2
  • Priority: high (labels must exist before the other drafts are published)
  • Agent: coder
  • Depends on: none
  • Decisions: Q-PROC-1

Why

Keeping labels in a file makes them reviewable and repeatable, and they can be recreated if the repository moves. The pipeline already has a Forgejo API helper that keeps the token off the command line.

What changes

  • .forgejo/labels.json (new). One object per label: name, color (hex without #), description, exclusive. The content is the table in #2, agent/ rows included (Q-PROC-1).
  • .forgejo/scripts/sync-labels.sh (new):
    • It sources .forgejo/scripts/forgejo-api.sh (inputs NINLIL_CI_TOKEN and FORGEJO_API, as in its header at lines 10-13).
    • It reads the repository as owner/name from an argument.
    • It lists the existing labels with forgejo_paginate /repos/{o}/{r}/labels.
    • It creates each missing label (POST /repos/{o}/{r}/labels) and updates any label whose colour, description or exclusive differs (PATCH /repos/{o}/{r}/labels/{id}).
    • It validates the file first and refuses to run when an exclusive label has no / (Forgejo ignores exclusivity without a scope) or when two labels have the same name. The scope is the text before the last / (FORGEJO-FACTS.md).
    • It never deletes a label, never touches issues, and prints one line per label: created, updated or unchanged.
    • It starts with the header block the comment standard requires for scripts, and the header states the rule for anyone who labels issues: never send two labels of one exclusive scope in one call, because Forgejo keeps both on create.
  • .forgejo/scripts/tests/sync-labels.test.sh (new). It follows cleanup.test.sh, using harness.sh and fake-forgejo.py with a routes file. Cases:
    • empty tracker → every label is POSTed;
    • one label with the wrong colour → one PATCH;
    • every label up to date → no write;
    • a labels file with an exclusive label without / → the script exits non-zero and sends nothing.
  • lint.sh picks up the test without a change (.forgejo/scripts/lint.sh:77).

Acceptance

  • The new test fails before the script exists, as an assertion on the request log, not as "file not found" only.
  • ./.forgejo/scripts/in-container.sh lint ./.forgejo/scripts/lint.sh ends with Lint passed.
  • The script's header names its inputs and outputs. No token appears on any command line.
  • AGENTS.md "Repository layout" needs no new row (.forgejo/scripts/ is listed). CONTRIBUTING.md gets one line naming the script (done in #5).

Source

  • BRIEF.md item (a). Existing helper: .forgejo/scripts/forgejo-api.sh:1-29. Test harness: .forgejo/scripts/tests/fake-forgejo.py:1-15. FORGEJO-FACTS.md (exclusive-label behaviour).
  • Owner decision 2026-10-31 (Q-PROC-1): "labels".
- **Draft:** PROC-2 - **Priority:** high (labels must exist before the other drafts are published) - **Agent:** coder - **Depends on:** none - **Decisions:** Q-PROC-1 ### Why Keeping labels in a file makes them reviewable and repeatable, and they can be recreated if the repository moves. The pipeline already has a Forgejo API helper that keeps the token off the command line. ### What changes - `.forgejo/labels.json` (new). One object per label: `name`, `color` (hex without `#`), `description`, `exclusive`. The content is the table in #2, `agent/` rows included (Q-PROC-1). - `.forgejo/scripts/sync-labels.sh` (new): - It sources `.forgejo/scripts/forgejo-api.sh` (inputs `NINLIL_CI_TOKEN` and `FORGEJO_API`, as in its header at lines 10-13). - It reads the repository as `owner/name` from an argument. - It lists the existing labels with `forgejo_paginate /repos/{o}/{r}/labels`. - It creates each missing label (`POST /repos/{o}/{r}/labels`) and updates any label whose colour, description or `exclusive` differs (`PATCH /repos/{o}/{r}/labels/{id}`). - It validates the file first and refuses to run when an `exclusive` label has no `/` (Forgejo ignores exclusivity without a scope) or when two labels have the same name. The scope is the text before the last `/` (FORGEJO-FACTS.md). - It never deletes a label, never touches issues, and prints one line per label: `created`, `updated` or `unchanged`. - It starts with the header block the comment standard requires for scripts, and the header states the rule for anyone who labels issues: never send two labels of one exclusive scope in one call, because Forgejo keeps both on create. - `.forgejo/scripts/tests/sync-labels.test.sh` (new). It follows `cleanup.test.sh`, using `harness.sh` and `fake-forgejo.py` with a routes file. Cases: - empty tracker → every label is POSTed; - one label with the wrong colour → one PATCH; - every label up to date → no write; - a labels file with an exclusive label without `/` → the script exits non-zero and sends nothing. - `lint.sh` picks up the test without a change (`.forgejo/scripts/lint.sh:77`). ### Acceptance - [ ] The new test fails before the script exists, as an assertion on the request log, not as "file not found" only. - [ ] `./.forgejo/scripts/in-container.sh lint ./.forgejo/scripts/lint.sh` ends with `Lint passed.` - [ ] The script's header names its inputs and outputs. No token appears on any command line. - [ ] AGENTS.md "Repository layout" needs no new row (`.forgejo/scripts/` is listed). CONTRIBUTING.md gets one line naming the script (done in #5). ### Source - BRIEF.md item (a). Existing helper: `.forgejo/scripts/forgejo-api.sh:1-29`. Test harness: `.forgejo/scripts/tests/fake-forgejo.py:1-15`. FORGEJO-FACTS.md (exclusive-label behaviour). - Owner decision 2026-10-31 (Q-PROC-1): "labels".
claude added this to the (deleted) milestone 2026-10-31 12:41:47 -04:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#3
No description provided.