refactor: split manage_labels.py into reusable modes (#6) #62

Merged
sysadmin merged 1 commits from feat/issue-6-manage-labels-modes into master 2026-07-02 05:24:34 -05:00
Owner

Closes #6.

What

Split manage_labels.py's one-shot backfill into reusable, mode-selected operations — default behavior preserved.

  • --create-labels — idempotent label creation only (create_labels()).
  • --apply-mapping — one-off MAPPING labeling only (apply_mapping(); PUT replaces each issue's label set).
  • --add-label <issue> <label> — ad-hoc single-issue labeling (add_label(); POST appends the label, does not replace; refuses an undefined label; validates numeric issue).
  • default (no mode) — create labels then apply MAPPING, identical to before. --dry (and --dry-run) still print without writing.

Extracted create_labels / apply_mapping / add_label / _labels_by_name. LABELS, MAPPING, and the api() wrapper unchanged. No auth/network behavior change.

Tests / checks

  • tests/test_manage_labels.py — added TestModes: create-only (no PUT), apply-only (no label creation), add-label appends (POST not PUT, correct id), unknown-label no-op, dry no-op, non-numeric issue exits. Existing default/dry/mapping/constant tests unchanged and pass.
  • py_compile clean; full suite (isolated worktree): 319 passed, 0 failures, 0 errors (JUnit XML); git diff --check clean; secret scan clean.

Files changed

manage_labels.py, tests/test_manage_labels.py.

Process

Isolated worktree: ./scripts/worktree-start feat/issue-6-manage-labels-modesbranches/feat-issue-6-manage-labels-modes.


⚠️ Authored by me — do not self-merge. Needs review by another author.

Closes #6. ## What Split `manage_labels.py`'s one-shot backfill into reusable, mode-selected operations — **default behavior preserved**. - `--create-labels` — idempotent label creation only (`create_labels()`). - `--apply-mapping` — one-off `MAPPING` labeling only (`apply_mapping()`; PUT replaces each issue's label set). - `--add-label <issue> <label>` — ad-hoc single-issue labeling (`add_label()`; **POST appends** the label, does not replace; refuses an undefined label; validates numeric issue). - **default (no mode)** — create labels then apply `MAPPING`, identical to before. `--dry` (and `--dry-run`) still print without writing. Extracted `create_labels` / `apply_mapping` / `add_label` / `_labels_by_name`. `LABELS`, `MAPPING`, and the `api()` wrapper unchanged. No auth/network behavior change. ## Tests / checks - `tests/test_manage_labels.py` — added `TestModes`: create-only (no PUT), apply-only (no label creation), add-label appends (POST not PUT, correct id), unknown-label no-op, dry no-op, non-numeric issue exits. Existing default/dry/mapping/constant tests unchanged and pass. - `py_compile` clean; full suite (isolated worktree): **319 passed, 0 failures, 0 errors** (JUnit XML); `git diff --check` clean; secret scan clean. ## Files changed `manage_labels.py`, `tests/test_manage_labels.py`. ## Process Isolated worktree: `./scripts/worktree-start feat/issue-6-manage-labels-modes` → `branches/feat-issue-6-manage-labels-modes`. --- ⚠️ Authored by me — do **not** self-merge. Needs review by another author.
jcwalker3 added 1 commit 2026-07-02 05:21:44 -05:00
Split the one-shot label backfill into reusable, mode-selected operations while
preserving the original default behavior:

- --create-labels : idempotent label creation only (create_labels()).
- --apply-mapping : one-off MAPPING labeling only (apply_mapping(); PUT replaces
  each issue's set).
- --add-label <issue> <label> : ad-hoc single-issue labeling (add_label(); POST
  appends the label, does not replace; refuses an undefined label).
- default (no mode) : create labels then apply MAPPING — identical to the prior
  behavior. --dry (and --dry-run) still print without writing.

Extracted create_labels / apply_mapping / add_label / _labels_by_name helpers;
LABELS, MAPPING, and the api() wrapper are unchanged. No auth/network behavior
change; MAPPING remains the same one-off backfill data.

Tests: extend tests/test_manage_labels.py with a TestModes suite — create-only
(no PUT), apply-only (no label creation), add-label appends (POST, not PUT),
unknown-label no-op, dry no-op, non-numeric issue exits. Existing default/dry/
mapping/constant tests unchanged and still pass.

py_compile clean; full suite 319 passed / 0 failures; git diff --check clean;
no secrets.

Closes #6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sysadmin merged commit 2d5cb4bb29 into master 2026-07-02 05:24:34 -05:00
Sign in to join this conversation.