* fix(gitlab): recognize work-item URLs on the configured self-hosted host (GH#6735)
IsExternalRef required the substring "gitlab" in the URL, so self-hosted
instances without it were treated as unlinked and sync created duplicate
issues. Also accept issue/work-item/milestone URLs whose host (and base
path) match the configured gitlab.url; unrelated hosts stay rejected.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* docs(gitlab): record the self-hosted ref fix and correct the BaseURL contract
Maintainer review fixups for #6736. The review found no blocker and no major;
these are its two gate-impact minors plus the two nearby nits. No behavior
change: the only non-comment edits are in the test.
- CHANGELOG had no entry for a user-visible change to which external refs the
GitLab tracker claims (6 of the 8 commits preceding the merge base touch it).
The bullet names GH#6735 and the two limits a reader actually needs: matching
is host-scoped, not project-scoped, and the host must be spelled the way
GitLab emits it in web_url.
- Client.BaseURL was documented as "https://gitlab.com/api/v4". That example was
already wrong before this PR -- buildURL appends DefaultAPIEndpoint itself, so
the documented form doubles the suffix -- but onConfiguredHost now makes the
web-root form load-bearing for ref identity, so a maintainer "fixing" a
construction site to match the comment would silently restore the duplicate
sync this PR fixes. WithEndpoint is that construction site: its doc said
"custom API endpoint" while assigning BaseURL. It has no production caller,
so both are doc-only corrections.
- onConfiguredHost now states the host-only match scope and the literal host
comparison. Both reviewers asked for these to be documented rather than
narrowed: keying the match on gitlab.project_path would drop self-hosted
recognition exactly where it is least likely to be configured, since that
key is optional and Init discards its load error.
- tracker_test: the milestone and shorthand rows are satisfied by the
pre-existing "milestones" substring and glShorthandPattern arms, so they pass
with onConfiguredHost deleted and overstated the table's coverage of the new
predicate. They are now grouped and labeled as regression pins for those arms,
and the two cases that do discriminate are added -- a scheme mismatch (claimed:
only the host is compared) and a non-default port (not claimed when the ref
omits it). Deleting `&& !t.onConfiguredHost(ref)` now fails 6 assertions, up
from 4.
Validation: gofmt, git diff --check, go vet ./internal/gitlab/,
golangci-lint ./internal/gitlab/... (0 issues), go test ./internal/gitlab/...
and go test ./cmd/bd/ -run 'GitLab|Gitlab', plus the counterfactual run above.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
* feat(gitlab): sync issue dependency links on push
After issue content syncs, mirror local beads dependency edges as GitLab
issue links: blocks -> GitLab blocks/is_blocked_by (direction-normalized),
related/relates-to -> a single relates_to link per unordered pair (deduped).
Children of synced epics also keep the epic's milestone during a
dependency-only sync. Reports links_pushed in --json.
Additive only (never deletes remote links). License-aware: blocks/
is_blocked_by needs GitLab Premium/Ultimate; on instances without it the
link is reported as a single curated, non-fatal message (links_license_skipped
in JSON) while relates_to and milestones still apply. Genuine (non-license)
link failures remain real warnings, kept distinct from the license case.
Feature: max-efe
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(gitlab): address review — drop dead RelationMap, add push link parity
Follow-up to maphew's review on #4294.
- Delete the dead GitLab RelationMap: issueLinksToDependencies maps link
types via hardcoded constants and ignores MappingConfig, so the field, its
default, and the test assertion were dead config surface implying a
configurability that does not exist. (Linear's RelationMap is untouched.)
- Give `bd gitlab push` dependency-link + epic-milestone parity with
`bd gitlab sync`: extract the shared pushGitLabDependencyLinks helper from
runGitLabSync's inline block and call it from runGitLabPush, scoped to the
requested IssueIDs. Render push output natively so the link pass runs
before the summary, dry-run ordering is correct, and the --json payload
carries links_pushed / links_license_skipped / milestones_updated, matching
sync in all output modes; also guard OnMessage under !jsonOutput.
Reviewed with /code-review + /codex (dry-run "Synced" line, output ordering,
and --json link-stat omission all caught and fixed here).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(gitlab): check outputJSON error in runGitLabSync (errcheck)
CI lint (first run on this branch, only-new-issues=false) flagged the
unchecked outputJSON return in the sync --json path. Return it, matching
runGitLabPush. Fixes the Lint / Build Artifacts / PR Lint failures.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(gitlab): carry closed state on push; surface failed-close in sync result
GitLab's POST /issues (and milestone/work-item creation) cannot set state,
so closed beads were pushed as opened issues and closed epics as active
milestones — milestone progress read 0/X even when all children were done.
- Close after create on all three paths (CreateIssue, createMilestone,
createTaskWorkItem) via a best-effort follow-up state_event=close.
- BeadsIssueToGitLabFields emits state_event close/reopen so the update path
flips both directions (reopening a bead reopens the GitLab issue). deferred
stays open — only "done" work counts toward milestone completion.
- A failed best-effort close now records a warning on TrackerIssue.Warnings,
which the engine drains into the sync result (visible in --json) instead of
a bare stderr print that left --json reporting errors:0 while the issue was
left open.
On close failure the created issue and its external_ref are still returned so
the next push doesn't create a duplicate (the push skip-guard means it won't
retry the close until the bead is next modified — hence the surfaced warning).
Reviewed via /code-review + Codex.
bd: max-9t6
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #3929 (GitHub tracker fix by @sealocal). The same bug
existed in jira, gitlab, ado, and notion trackers: their getConfig()
methods read every key from the Dolt store, but secret keys (API
tokens, PATs) should never be in the database because it gets pushed
to remotes, triggering secret-scanning blocks.
Changes:
- Add jira.api_token, gitlab.token, ado.pat to the yaml-only key
list so they are stored in config.yaml (not the Dolt database),
consistent with github.token and linear.api_key.
- Add IsYamlOnlyKey guard to getConfig() in all four trackers,
mirroring the pattern in linear/tracker.go and the merged GitHub
tracker fix.
- Add regression tests (nil-store bypass + yaml-read) for jira,
gitlab, and ado; defensive yaml-only path test for notion.
- Update existing tests that put secret keys in mock stores to use
t.Setenv instead, matching the new yaml-only behavior.
Co-Authored-By: sealocal <4951910+sealocal@users.noreply.github.com>
- Fix pull dedup: check wisps table and match work_items URLs
- Add type-based filtering to GitLab sync CLI
- Default-exclude molecule/message/event types from push
- Fix source_system update that breaks external_ref persistence
- Map all beads statuses to GitLab scoped labels for board columns
- Handle status::review and status::done labels on pull
- Map epic beads to GitLab milestones instead of issues
- Create task beads as GitLab Task work items with parent hierarchy
- Walk parent chain to find epic milestone, use API ID not IID
Co-authored-by: ktoulgaridis <ktoulg@gmail.com>
Executed-By: beads/crew/emma
* fix: recognize ado:NNNNN shorthand in IsExternalRef and ExtractIdentifier
IsExternalRef and ExtractIdentifier only matched full ADO URLs
(/_workitems/edit/\d+), but BuildExternalRef produces ado:NNNNN
shorthand when org/project config is unavailable. This caused the
sync engine to treat existing beads as new, creating duplicate ADO
work items instead of updating existing ones.
Fixes harry-miller-trimble/beads#28
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: add shorthand ref support to GitHub/GitLab trackers, tighten ado:0
Address PR #2966 review feedback:
- GitHub tracker: add ghShorthandPattern (github:{id}) to IsExternalRef
and ExtractIdentifier, fixing the same duplicate-creation bug as ADO
- GitLab tracker: add glShorthandPattern (gitlab:{id}) to IsExternalRef
and ExtractIdentifier, fixing the same duplicate-creation bug as ADO
- ADO tracker: tighten regex from ^ado:(\d+)$ to ^ado:([1-9]\d*)$ to
reject ado:0 which is invalid in practice
- Add test cases for shorthand format in all three trackers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move IssueTracker implementations from internal/tracker/adapters/{linear,gitlab}/
directly into internal/{linear,gitlab}/ and create a new minimal Jira tracker.
Each package now registers itself via init(), eliminating the adapter indirection
layer. Delete the adapters/ directory entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 16:18:37 -08:00
Renamed from internal/tracker/adapters/gitlab/adapter_test.go (Browse further)