-
Notifications
You must be signed in to change notification settings - Fork 32
feat: full GitLab integration — parity with GitHub #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+6,417
−135
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
558ba24
feat(backend): full GitLab parity — store, service, poller, WS, presets
4f25143
feat(web): GitLab frontend parity — types, API, store slice, domain h…
0de39f0
fix(gitlab): wire orchestrator event handlers, fix label-filter drop,…
4519cf3
fix(gitlab): address remaining blockers — cleanup wiring, safe defaul…
fa68e2e
fix(gitlab): propagate session-check errors, clamp poll interval on u…
30dca5b
fix(gitlab): clear dupl lint, fix preset retry loop + per-workspace w…
6e5bbb3
fix(gitlab): add nil-store guards across review/issue watch + cleanup…
244285e
fix(gitlab): nil-store guards on CheckXxxWatch + DeleteXxxWatch + cle…
a1a31fd
refactor(gitlab): split service_watches.go to stay under 800-line rev…
f2c2866
fix(gitlab): address inline code-review feedback
698fa8b
ci: re-trigger to clear flaky E2E shard 3
36c9bd6
fix(gitlab): address final review round — nil guards, store merge, lo…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package gitlab | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| ) | ||
|
|
||
| // GetActionPresetsOrDefault returns the workspace's stored presets, falling | ||
| // back to the built-in defaults when none are stored. | ||
| func (s *Service) GetActionPresetsOrDefault(ctx context.Context, workspaceID string) (*ActionPresets, error) { | ||
| store := s.requireStore() | ||
|
jcfs marked this conversation as resolved.
jcfs marked this conversation as resolved.
|
||
| if store == nil { | ||
| return defaultPresets(workspaceID), nil | ||
| } | ||
| presets, err := store.GetActionPresets(ctx, workspaceID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("get action presets: %w", err) | ||
| } | ||
| if len(presets.MR) == 0 { | ||
| presets.MR = DefaultMRActionPresets() | ||
| } | ||
| if len(presets.Issue) == 0 { | ||
| presets.Issue = DefaultIssueActionPresets() | ||
| } | ||
| return presets, nil | ||
| } | ||
|
|
||
| // UpdateActionPresets persists a partial update to a workspace's presets. | ||
| // Nil fields are left unchanged. Untouched kinds are NOT filled with current | ||
| // defaults before persistence — that would freeze stale defaults into the | ||
| // workspace row, masking future default changes. The reader | ||
| // (GetActionPresetsOrDefault) substitutes defaults on read instead. | ||
| func (s *Service) UpdateActionPresets(ctx context.Context, req *UpdateActionPresetsRequest) (*ActionPresets, error) { | ||
| if req == nil || req.WorkspaceID == "" { | ||
| return nil, fmt.Errorf("workspace_id required") | ||
| } | ||
| store := s.requireStore() | ||
| if store == nil { | ||
| return nil, fmt.Errorf("gitlab store not configured") | ||
| } | ||
| current, err := store.GetActionPresets(ctx, req.WorkspaceID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("get action presets: %w", err) | ||
| } | ||
| if current == nil { | ||
| current = &ActionPresets{WorkspaceID: req.WorkspaceID} | ||
| } | ||
| if req.MR != nil { | ||
| current.MR = *req.MR | ||
| } | ||
| if req.Issue != nil { | ||
| current.Issue = *req.Issue | ||
| } | ||
| if err := store.UpsertActionPresets(ctx, current); err != nil { | ||
| return nil, fmt.Errorf("upsert action presets: %w", err) | ||
| } | ||
| // Return the rendered view (defaults substituted) so the caller sees the | ||
| // same shape the read endpoint produces. | ||
| return s.GetActionPresetsOrDefault(ctx, req.WorkspaceID) | ||
| } | ||
|
|
||
| // ResetActionPresets removes a workspace's stored presets, falling back to defaults. | ||
| func (s *Service) ResetActionPresets(ctx context.Context, workspaceID string) (*ActionPresets, error) { | ||
| if workspaceID == "" { | ||
| return nil, fmt.Errorf("workspace_id required") | ||
| } | ||
| store := s.requireStore() | ||
| if store == nil { | ||
| return defaultPresets(workspaceID), nil | ||
| } | ||
| if err := store.DeleteActionPresets(ctx, workspaceID); err != nil { | ||
| return nil, fmt.Errorf("reset action presets: %w", err) | ||
| } | ||
| return defaultPresets(workspaceID), nil | ||
| } | ||
|
|
||
| func defaultPresets(workspaceID string) *ActionPresets { | ||
| return &ActionPresets{ | ||
| WorkspaceID: workspaceID, | ||
| MR: DefaultMRActionPresets(), | ||
| Issue: DefaultIssueActionPresets(), | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package gitlab | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestService_GetActionPresetsOrDefault_FallsBackToDefaults(t *testing.T) { | ||
| svc := newServiceWithStore(t) | ||
| got, err := svc.GetActionPresetsOrDefault(context.Background(), "ws-new") | ||
| if err != nil { | ||
| t.Fatalf("GetActionPresetsOrDefault: %v", err) | ||
| } | ||
| if got == nil { | ||
| t.Fatalf("expected non-nil presets") | ||
| } | ||
| if len(got.MR) == 0 || len(got.Issue) == 0 { | ||
| t.Fatalf("expected defaults to be injected when none stored, got %+v", got) | ||
| } | ||
| if got.MR[0].ID == "" { | ||
| t.Fatalf("default presets missing ID: %+v", got.MR[0]) | ||
| } | ||
| } | ||
|
|
||
| func TestService_UpdateActionPresets_PartialMerge(t *testing.T) { | ||
| svc := newServiceWithStore(t) | ||
| ctx := context.Background() | ||
| // First write only MR presets. | ||
| mrPresets := []ActionPreset{{ID: "x", Label: "Custom", PromptTemplate: "do {{url}}"}} | ||
| if _, err := svc.UpdateActionPresets(ctx, &UpdateActionPresetsRequest{ | ||
| WorkspaceID: "ws-1", | ||
| MR: &mrPresets, | ||
| }); err != nil { | ||
| t.Fatalf("UpdateActionPresets: %v", err) | ||
| } | ||
| // Read back: MR should be custom, Issue should still be defaults (from | ||
| // GetActionPresetsOrDefault). | ||
| got, err := svc.GetActionPresetsOrDefault(ctx, "ws-1") | ||
| if err != nil { | ||
| t.Fatalf("get: %v", err) | ||
| } | ||
| if len(got.MR) != 1 || got.MR[0].ID != "x" { | ||
| t.Fatalf("MR presets not persisted: %+v", got.MR) | ||
| } | ||
| if len(got.Issue) == 0 { | ||
| t.Fatalf("Issue presets should fallback to defaults when empty") | ||
| } | ||
| } | ||
|
|
||
| func TestService_ResetActionPresets(t *testing.T) { | ||
| svc := newServiceWithStore(t) | ||
| ctx := context.Background() | ||
| custom := []ActionPreset{{ID: "x", Label: "x"}} | ||
| if _, err := svc.UpdateActionPresets(ctx, &UpdateActionPresetsRequest{ | ||
| WorkspaceID: "ws-1", | ||
| MR: &custom, | ||
| }); err != nil { | ||
| t.Fatalf("UpdateActionPresets: %v", err) | ||
| } | ||
| got, err := svc.ResetActionPresets(ctx, "ws-1") | ||
| if err != nil { | ||
| t.Fatalf("ResetActionPresets: %v", err) | ||
| } | ||
| if len(got.MR) == 0 || got.MR[0].ID == "x" { | ||
| t.Fatalf("reset should restore defaults, got %+v", got.MR) | ||
| } | ||
| } | ||
|
|
||
| func newServiceWithStore(t *testing.T) *Service { | ||
| t.Helper() | ||
| store := newTestStore(t) | ||
| log := newTestLogger(t) | ||
| svc := NewService("https://gitlab.com", NewNoopClient("https://gitlab.com"), AuthMethodNone, nil, log) | ||
| svc.SetStore(store) | ||
| return svc | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.