Skip to content

feat: add Bitbucket workspace support for PR complexity analysis#4

Merged
OhadPerryBoomi merged 3 commits intomainfrom
feat/bitbucket-support
Mar 11, 2026
Merged

feat: add Bitbucket workspace support for PR complexity analysis#4
OhadPerryBoomi merged 3 commits intomainfrom
feat/bitbucket-support

Conversation

@OhadPerryBoomi
Copy link
Collaborator


This PR was opened using this rule: https://github.com/RiveryIO/rivery-cursor-rules/blob/main/administrative/github-pr.md


Description

Adds full Bitbucket workspace support so the complexity analyzer can scan and tag PRs from both GitHub and Bitbucket in a single pipeline.

What changed

  • New cli/bitbucket.py — Bitbucket API client: fetch PR diffs, metadata, discover project repos, search merged PRs, post complexity comments (with <!-- [complexity-analyzer] --> marker for idempotency).
  • cli/utils.pyparse_pr_url() now accepts both GitHub and Bitbucket URLs (same 3-tuple return — backward-compatible). Added detect_pr_provider().
  • cli/csv_handler.py — Added source column (auto-detected from URL, appended at end so existing data is unaffected). pandas.read_csv() in reports handles missing column gracefully.
  • cli/main.pyanalyze_pr_to_dict() and dry-run path route to GH or BB fetch based on URL. New --bb-project option on batch-analyze.
  • cli/batch.pygenerate_pr_list_from_bb_project() discovers repos by project UUID, collects merged PRs. Label check/apply routes to BB comments for Bitbucket URLs. Source-filtered incremental fetch (get_max_merged_for_source).
  • cli/analyze.py — Both analyze_single_pr() and handle_dry_run() route by provider.
  • cli/config.pyget_bitbucket_credentials() reads BITBUCKET_EMAIL + BITBUCKET_API_TOKEN.
  • cli/migrate.py — Backfills source column from URL; skips GitHub API enrichment for BB rows.
  • scripts/sync-new-prs.sh — Two-pass daily sync: Pass 1 (GitHub via --repos-file), Pass 2 (Bitbucket via --bb-project). Supports SKIP_GH=1 / SKIP_BB=1 env vars.
  • complexity-report.csv — Rewritten with source column, sorted by date. Includes 12 initial Bitbucket PR scores.
  • Tests — New tests for BB URL parsing, detect_pr_provider(), BB source auto-detection in CSV writer, updated verify test fixture.

Backward compatibility

  • parse_pr_url() return type unchanged (3-tuple) — zero caller changes needed.
  • source column added at end of CSV schema — existing pd.read_csv() consumers unaffected.
  • Running migrate-csv on old CSVs backfills source as "github" automatically.

Testing

  • All 38 unit tests pass (test_utils, test_csv_handler, test_verify)
  • Live smoke test: fetched BB PR #41 diff + metadata successfully
  • Live batch: discovered 9 repos in BB project, analyzed and tagged 12 merged PRs
  • BB comments posted with complexity scores and verified via API
  • CSV rewritten with source column, reports generate without errors

Usage

# Single BB PR analysis
complexity-cli analyze-pr "https://bitbucket.org/workspace/repo/pull-requests/41"

# Batch: scan entire BB project
complexity-cli batch-analyze --bb-project "workspace/{project-uuid}" --days 14 --output complexity-report.csv --label

# Daily sync (both sources)
./scripts/sync-new-prs.sh --days 14

Scan and tag Bitbucket PRs alongside GitHub. Adds cli/bitbucket.py API
client (diff, metadata, project repo discovery, merged PR search,
complexity comments). Extends parse_pr_url and CSV schema with a
`source` column (auto-detected, backward-compatible). Updates
sync-new-prs.sh with a second Bitbucket pass (BB_PROJECT env var).
Includes 12 initial Bitbucket PR scores in complexity-report.csv.

Made-with: Cursor
Run black on all changed files to pass CI format check.
Update test_invalid_pr_url assertions to accept the new
"Unrecognized PR URL" message from multi-provider URL parsing.

Made-with: Cursor
@OhadPerryBoomi OhadPerryBoomi merged commit b01a1a1 into main Mar 11, 2026
6 checks passed
@OhadPerryBoomi OhadPerryBoomi deleted the feat/bitbucket-support branch March 11, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant