beads/internal/gitlab
Vishnu J a8a6c67413
Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736)
* 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>
2026-09-26 04:15:47 -07:00
..
client.go Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736) 2026-09-26 04:15:47 -07:00
client_test.go feat: add optional group-level GitLab issue sync (PR #2801) 2026-03-26 19:31:45 -07:00
fieldmapper.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
links.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
links_test.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
mapping.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
mapping_test.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
tracker.go Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736) 2026-09-26 04:15:47 -07:00
tracker_state_test.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00
tracker_test.go Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736) 2026-09-26 04:15:47 -07:00
types.go Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736) 2026-09-26 04:15:47 -07:00
types_test.go style: run gofmt across entire codebase (bd-nmk12) 2026-02-07 19:35:20 -08:00