Skip to content

Add BitBucket Cloud scaffolding#775

Draft
maciekbanas wants to merge 1 commit into
masterfrom
mb/bitbucket-scaffolding
Draft

Add BitBucket Cloud scaffolding#775
maciekbanas wants to merge 1 commit into
masterfrom
mb/bitbucket-scaffolding

Conversation

@maciekbanas
Copy link
Copy Markdown
Member

@maciekbanas maciekbanas commented Apr 7, 2026

Description

Introduces BitBucket Cloud (api.bitbucket.org/2.0) as a third supported Git host alongside GitHub and GitLab. BitBucket Cloud uses REST API v2 only (no GraphQL).

New classes:

  • EngineRestBitBucket — REST engine with BitBucket-style cursor pagination (next URL), repo listing, commit retrieval with client-side date filtering, contributors approximation from recent commits, and file tree browsing.
  • GitHostBitBucket — REST-only host subclass. Overrides org/repo/commit retrieval to use REST, workspace validation, and repos data caching. Unsupported methods (get_issues, get_pull_requests, get_release_logs, get_files content, get_users) raise informative errors.

New exported function:

  • set_bitbucket_host() — follows the same pattern as set_github_host() / set_gitlab_host(). BitBucket workspaces map to the orgs parameter.

Currently supports: get_repos(), get_commits(), get_orgs(), get_repos_trees().

Notable design decisions:

  • No GraphQL engine — private$engines$graphql is NULL; all base class methods that delegate to GraphQL are overridden.
  • Contributors approximated from unique authors in the last 100 commits (BitBucket has no /contributors endpoint).
  • Commit additions/deletions set to NA (requires separate diffstat API call — deferred to get_commits() support #770).
  • Token validation uses GET /user success (HTTP 200) since BitBucket doesn't return scope headers.

Note: roxygen2::roxygenise() needs to be run to regenerate man pages for set_bitbucket_host before merging.

Related Issue(s)

Closes #768
Part of #754

How to test

  1. Unit tests: testthat::test_file(\"tests/testthat/test-set_host-BitBucket.R\")
  2. Manual (requires a BitBucket Cloud app password with repository scope):
library(GitStats)
gs <- create_gitstats() |>
  set_bitbucket_host(
    token = Sys.getenv("BITBUCKET_PAT"),
    orgs = "your_workspace"
  )
gs |> get_repos()
gs |> get_commits(since = "2024-01-01", until = "2024-12-31")
  1. Run R CMD check to verify no regressions.

…t, set_bitbucket_host()

Introduce BitBucket Cloud (api.bitbucket.org/2.0) as a third supported
Git host. BitBucket uses REST API only (no GraphQL).

New classes:
- EngineRestBitBucket: REST engine with cursor-based pagination,
  repo listing, commit retrieval, contributors approximation, and
  file tree browsing.
- GitHostBitBucket: REST-only host subclass. Overrides org/repo/commit
  retrieval. Unsupported methods raise informative errors.

New exported function:
- set_bitbucket_host(): follows the same pattern as set_github_host()
  and set_gitlab_host().

Currently supports: get_repos(), get_commits(), get_orgs(),
get_repos_trees(). Other methods will be added incrementally.

Closes #768

Co-authored-by: Ona <no-reply@ona.com>
@maciekbanas maciekbanas added bitbucket BitBucket-specific enhancement New feature or improvement labels Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bitbucket BitBucket-specific enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core scaffolding — EngineRestBitBucket, GitHostBitBucket, set_bitbucket_host()

1 participant