Add robust Bitbucket Cloud scope handling and coverage#138
Conversation
There was a problem hiding this comment.
Pull request overview
Improves Bitbucket Cloud repo scoping in the gh-devlake CLI by making remote-scope browsing fail fast on pagination errors, adds unit coverage for Bitbucket repo parsing, and updates scope documentation to include Bitbucket.
Changes:
- Propagate pagination errors when listing Bitbucket workspaces/repos during interactive browsing.
- Add unit tests for
parseBitbucketRepoto validate payload-field precedence and fallback behavior. - Update
configure scope adddocs to include Bitbucket and expand plugin/flag descriptions and examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs/configure-scope.md | Expands scope-add docs to include Bitbucket (and other plugins) plus Bitbucket “What It Does”. |
| cmd/configure_scopes_test.go | Adds test coverage for Bitbucket remote-scope child parsing. |
| cmd/configure_scopes.go | Changes Bitbucket remote-scope pagination to return errors instead of silently breaking. |
| | `--repos` | | Comma-separated repos to add (`owner/repo,owner/repo2`) for GitHub, GitLab, Bitbucket | | ||
| | `--repos-file` | | Path to a file with repos (one `owner/repo` per line) for GitHub, GitLab, Bitbucket | |
There was a problem hiding this comment.
The --repos / --repos-file descriptions show owner/repo as the canonical format for GitLab and Bitbucket as well, but those plugins use group/project (GitLab) and workspace/repo-slug (Bitbucket). Updating the wording/examples here would prevent users from passing the wrong repo slug format.
| | `--repos` | | Comma-separated repos to add (`owner/repo,owner/repo2`) for GitHub, GitLab, Bitbucket | | |
| | `--repos-file` | | Path to a file with repos (one `owner/repo` per line) for GitHub, GitLab, Bitbucket | | |
| | `--repos` | | Comma-separated repos to add (`owner/repo` for GitHub, `group/project` for GitLab, `workspace/repo-slug` for Bitbucket) | | |
| | `--repos-file` | | Path to a file with repos (one per line: `owner/repo` for GitHub, `group/project` for GitLab, `workspace/repo-slug` for Bitbucket) | |
| t.Run("falls back to child fields when payload is sparse", func(t *testing.T) { | ||
| child := devlake.RemoteScopeChild{ | ||
| Name: "frontend", | ||
| FullName: "team/frontend", | ||
| Data: []byte(`{"bitbucketId":"","name":"","fullName":""}`), | ||
| } | ||
| repo := parseBitbucketRepo(&child) |
There was a problem hiding this comment.
parseBitbucketRepo currently returns nil when child.Data is missing/empty (json.Unmarshal on a nil RawMessage fails). DevLake remote-scope responses can omit the data field entirely, so this test suite should include a case with Data: nil (or empty) and expect fallback to child.Name/child.FullName; otherwise interactive Bitbucket repo browsing/search can silently drop repos.
| | `--plugin` | *(interactive or required)* | Plugin to configure (`github`, `gitlab`, `bitbucket`, `gh-copilot`, `jenkins`, `azure-devops`, `sonarqube`) | | ||
| | `--connection-id` | *(auto-detected)* | Override the connection ID to scope | | ||
| | `--org` | *(required)* | GitHub organization slug | | ||
| | `--org` | *(required)* | Org/workspace slug (`github`, `gitlab` group path, `bitbucket` workspace, `azure-devops` org) | |
There was a problem hiding this comment.
The docs mark --org as (required) for configure scope add, but in the CLI this is only required for plugins whose ConnectionDef has NeedsOrg set (e.g., Azure DevOps). Bitbucket repo scoping supports omitting --org and will prompt to select a workspace interactively, so the docs should reflect that --org is plugin-dependent/optional in interactive mode (and clarify which plugins require it).
| | `--org` | *(required)* | Org/workspace slug (`github`, `gitlab` group path, `bitbucket` workspace, `azure-devops` org) | | |
| | `--org` | *(plugin-dependent)* | Org/workspace slug (`github`, `gitlab` group path, `bitbucket` workspace, `azure-devops` org). Required for plugins whose connection definition needs an org (for example, Azure DevOps) or when running non-interactively; optional in interactive mode for plugins that support workspace discovery (for example, Bitbucket). | |
|
@codex[agent] Please address the three review comments on this PR: 1) fix the docs wording for |
Addressed: updated scope docs for plugin-specific repo formats and plugin-dependent org wording, added parseBitbucketRepo test for nil/empty data fallback, and reran build/test/vet (bef8588). |
ewega
left a comment
There was a problem hiding this comment.
Reviewed after follow-up fixes; safe to merge.
Bitbucket Cloud needed reliable scope selection and documentation for BasicAuth-based connections and remote-scope browsing.
parseBitbucketRepoto tolerate missingdatapayloads by falling back to child fields.parseBitbucketRepounit coverage to ensure bitbucketId/name/fullName fallbacks and payload fields are honored, including nil/empty data cases.Example: