Add Bitbucket Data Center pull request source support#261
Add Bitbucket Data Center pull request source support#261
Conversation
Add a new BitbucketDataCenterPRs source type to TaskSpawner that discovers pull requests from Bitbucket Data Center repositories. This allows teams using Bitbucket DC to leverage automated task spawning for PR review and processing. Changes: - Add BitbucketDataCenterPRs API type with state filter (OPEN, MERGED, DECLINED, ALL) - Implement BitbucketDataCenterSource using the Bitbucket DC REST API (/rest/api/1.0) with pagination and Bearer token authentication - Parse Bitbucket DC repository URLs (SCM clone, browse, SSH formats) - Wire up deployment builder, spawner, and CLI printer for the new source - Add unit tests, integration tests, and example manifests Fixes #260 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
2 issues found across 18 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="test/integration/taskspawner_test.go">
<violation number="1" location="test/integration/taskspawner_test.go:709">
P2: Missing `HaveLen(1)` assertion on `Containers` before indexing `[0]`. The first Bitbucket DC test correctly guards with `Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))` before accessing `Containers[0]`, but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.</violation>
</file>
<file name="internal/source/bitbucket_dc.go">
<violation number="1" location="internal/source/bitbucket_dc.go:173">
P2: Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while `fetchAllPRs` properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to `fetchAllPRs`, or at minimum paginating until `maxCommentBytes` is reached.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| By("Verifying the Deployment spec has Bitbucket DC args") | ||
| Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1)) | ||
| container := createdDeploy.Spec.Template.Spec.Containers[0] |
There was a problem hiding this comment.
P2: Missing HaveLen(1) assertion on Containers before indexing [0]. The first Bitbucket DC test correctly guards with Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1)) before accessing Containers[0], but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/integration/taskspawner_test.go, line 709:
<comment>Missing `HaveLen(1)` assertion on `Containers` before indexing `[0]`. The first Bitbucket DC test correctly guards with `Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))` before accessing `Containers[0]`, but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.</comment>
<file context>
@@ -626,6 +626,196 @@ var _ = Describe("TaskSpawner Controller", func() {
+
+ By("Verifying the Deployment spec has Bitbucket DC args")
+ Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))
+ container := createdDeploy.Spec.Template.Spec.Containers[0]
+ Expect(container.Name).To(Equal("spawner"))
+ Expect(container.Image).To(Equal(controller.DefaultSpawnerImage))
</file context>
| container := createdDeploy.Spec.Template.Spec.Containers[0] | |
| Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1)) | |
| container := createdDeploy.Spec.Template.Spec.Containers[0] |
| return prs, page.NextPageStart, page.IsLastPage, nil | ||
| } | ||
|
|
||
| func (s *BitbucketDataCenterSource) fetchPRComments(ctx context.Context, prID int) (string, error) { |
There was a problem hiding this comment.
P2: Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while fetchAllPRs properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to fetchAllPRs, or at minimum paginating until maxCommentBytes is reached.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/source/bitbucket_dc.go, line 173:
<comment>Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while `fetchAllPRs` properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to `fetchAllPRs`, or at minimum paginating until `maxCommentBytes` is reached.</comment>
<file context>
@@ -0,0 +1,225 @@
+ return prs, page.NextPageStart, page.IsLastPage, nil
+}
+
+func (s *BitbucketDataCenterSource) fetchPRComments(ctx context.Context, prID int) (string, error) {
+ u := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d/activities",
+ s.BaseURL, s.Project, s.Repo, prID)
</file context>
Summary
BitbucketDataCenterPRsas a new source type forTaskSpawner, enabling teams using Bitbucket Data Center to leverage automated task spawning for PR review and processingBitbucketDataCenterSourceusing the Bitbucket DC REST API (/rest/api/1.0) with pagination support and Bearer token authentication/scm/PROJECT/repo), browse URLs (/projects/PROJECT/repos/repo), and SSH URLsTest plan
BitbucketDataCenterSource(discovery, pagination, state filtering, auth, comments, error handling)parseBitbucketDCRepo(all URL formats)buildSourcewith Bitbucket DC PRsmake verifypassesmake testpassesmake test-integrationpasses (39/39 specs)Fixes #260
🤖 Generated with Claude Code
Summary by cubic
Adds Bitbucket Data Center pull request source to TaskSpawner so teams can auto-spawn tasks for PR review on Bitbucket DC. Addresses task #260 with REST API integration, URL parsing, CRD updates, and CLI wiring.
New Features
Migration
Written for commit b8560f0. Summary will update on new commits.