Commit graph

12 commits

Author SHA1 Message Date
Kyriakos Toulgaridis
9dc3264663
feat: add optional group-level GitLab issue sync (PR #2801)
* feat: add optional group-level GitLab issue sync (be-711)

When gitlab.group_id is configured, FetchIssues and FetchIssuesSince
use the /groups/:id/issues API endpoint to aggregate issues across all
projects in the group. Issue creation still uses the project endpoint
(via gitlab.project_id or gitlab.default_project_id).

New config keys:
- gitlab.group_id / GITLAB_GROUP_ID
- gitlab.default_project_id / GITLAB_DEFAULT_PROJECT_ID

Backward compatible: existing project-level sync is unchanged when
group_id is not set.

* feat: add filtering support to GitLab group sync (be-4js)

Add optional filters for labels, project, milestone, and assignee to
the GitLab issue sync. Filters work on both project and group endpoints.

Filters can be set via config (gitlab.filter_labels, etc.), environment
variables (GITLAB_FILTER_LABELS, etc.), or CLI flags (--label, --project,
--milestone, --assignee). CLI flags override config defaults.

Labels, milestone, and assignee are passed as GitLab API query params.
Project filtering within a group is done client-side since the GitLab
group issues API doesn't support it natively.
2026-03-26 19:31:45 -07:00
jane
af4caf0573 test: add tests for 5xx retry and delete cache invalidation
- TestServerErrorRetry: verifies 500/502/503/504 are retried with backoff
- TestNonRetriableError: verifies 403 is NOT retried
- TestDeleteIssue_InvalidatesBlockedCache: verifies single delete clears cache
- TestDeleteIssues_InvalidatesBlockedCache: verifies batch delete clears cache
- Update TestFetchIssuesSince_Error with short timeout (500s now retried)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:59:20 -08:00
beads/crew/lizzy
2bb827facb style: run gofmt across entire codebase (bd-nmk12)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:35:20 -08:00
jane
309bab48db fix: resolve failing tests in daemon autostart, gitlab, and syncbranch
- daemon_autostart.go: Add stubbable function variables for isDoltBackend
  and singleProcessOnlyBackend to allow tests to bypass backend checks
  when testing env var behavior
- autostart_test.go: Stub out backend checks in TestDaemonAutoStart
- daemon_autostart_unit_test.go: Stub out backend checks in
  TestDaemonAutostart_StartDaemonProcess_Stubbed
- client_test.go: Update context cancellation tests to accept either
  context.Canceled or pagination limit exceeded as valid loop termination
  (both prevent infinite loops which is what the tests verify)
- ensure_worktree_test.go: Resolve symlinks before comparing paths in
  TestFreshCloneScenario (fixes macOS /var -> /private/var symlink issue)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:19:00 -08:00
Joseph Turian
6f89e6559e fix(test): use atomic counter in TestFetchIssues_ContextCancellation
Same data race fix as the other gitlab test - requestCount is accessed
from both the HTTP handler goroutine and the test goroutine.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 02:40:47 -08:00
Joseph Turian
f5b7025302 fix(test): use atomic counter to fix data race in gitlab test
TestFetchIssuesSince_ContextCancellation had a data race where
requestCount was written by the HTTP handler goroutine and read
by the test goroutine without synchronization.

Use sync/atomic.Int64 to make the counter thread-safe.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 01:55:48 -08:00
obsidian
a7f9e86319 fix: resolve remaining errcheck violations in gitlab files
Add explicit error suppression (`_ =`) for unchecked resp.Body.Close()
in internal/gitlab/client.go and unchecked json.NewEncoder, w.Write,
json.NewDecoder, and os.Setenv/Unsetenv calls in gitlab test files.
Replace os.Setenv/Unsetenv with t.Setenv in gitlab_test.go for
automatic cleanup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-02 15:09:06 -07:00
Ramos
745002eeac fix(gitlab): P2 - fix error handling and type safety
- Fix swallowed json.Marshal error during retry (client.go line 114)
  Now logs the error and continues to next retry attempt instead of
  silently ignoring with _.

- Add GetIssue() helper to IssueConversion for type-safe access
  Returns *types.Issue from interface{} field, nil if wrong type.
  Avoids import cycle by keeping interface{} but providing safe accessor.

- Eliminate duplicate mapping definitions between types.go and mapping.go
  Export PriorityMapping, StatusMapping, TypeMapping from types.go as
  single source of truth. DefaultMappingConfig now uses these exports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:47 -08:00
Ramos
f9f3a03ad6 fix(gitlab): P1 - add pagination limit and context cancellation
Add safeguards to prevent infinite loops in FetchIssues and FetchIssuesSince:

1. MaxPages constant (1000) prevents runaway pagination from malformed
   X-Next-Page headers that never return empty
2. Context cancellation check at start of each pagination loop iteration
   allows graceful shutdown and returns partial results when cancelled
   between requests

Fixes potential DoS from malformed GitLab responses and improves
responsiveness to cancellation signals.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:46 -08:00
Ramos
f271075976 Add unit tests for GitLab backend (Issue #10)
Improve test coverage from 82.3% to 92.2% for internal/gitlab package:

- types_test.go: Add tests for GetPriorityFromLabel, GetStatusFromLabel,
  GetTypeFromLabel helper functions (0% → 100%)
- mapping_test.go: Add tests for priorityToLabel (42.9% → 100%) and
  IssueLinksToDependencies edge cases (73.3% → 100%)
- client_test.go: Add error handling tests for UpdateIssue, GetIssueLinks,
  FetchIssueByIID, CreateIssueLink, CreateIssue, FetchIssuesSince

All 379 new lines of tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:45 -08:00
Ramos
70e5cc1615 Add review fixes: URL encoding, WithEndpoint, FetchIssueByIID, CreateIssueLink
Code review identified these issues:
- ProjectID now URL-encoded via projectPath() helper for path-based IDs
- Added WithEndpoint() builder for custom API endpoints
- Added FetchIssueByIID() for fetching single issues
- Added CreateIssueLink() for creating issue dependencies

All 15 client tests pass. Ready for sync implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:43 -08:00
Ramos
abbc0914ec feat(gitlab): implement GitLab REST API client wrapper
TDD implementation of GitLab client for beads integration:
- NewClient constructor with builder pattern (WithHTTPClient)
- FetchIssues with pagination support via X-Next-Page header
- FetchIssuesSince for incremental sync with updated_after param
- CreateIssue for POST /projects/:id/issues
- UpdateIssue for PUT /projects/:id/issues/:iid
- GetIssueLinks for GET /projects/:id/issues/:iid/links
- Retry logic with exponential backoff for rate limiting (429)
- Proper error handling with status code context

All 11 new tests pass (19 total in gitlab package).

Closes #5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-31 00:01:42 -08:00