Files
tracer-cloud--opensre/integrations/bitbucket/tools/bitbucket_commits_tool/__init__.py
T
wehub-resource-sync 4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

88 lines
2.7 KiB
Python

"""Bitbucket Commits Tool."""
from __future__ import annotations
from typing import Any
from core.tool_framework.tool_decorator import tool
from integrations.bitbucket import list_commits
from integrations.bitbucket.availability import bitbucket_available_or_backend
from integrations.bitbucket.tools.bitbucket_search_code_tool import (
_bb_creds,
_resolve_config,
)
def _list_bitbucket_commits_extract_params(sources: dict[str, dict]) -> dict[str, Any]:
bb = sources["bitbucket"]
return {
"repo_slug": bb.get("repo_slug", bb.get("repo", "")),
"path": bb.get("path", ""),
"limit": 20,
**_bb_creds(bb),
}
def _list_bitbucket_commits_available(sources: dict[str, dict]) -> bool:
bb = sources.get("bitbucket", {})
return bool(bitbucket_available_or_backend(sources) and bb.get("repo_slug", bb.get("repo")))
@tool(
name="list_bitbucket_commits",
description="List recent commits for a Bitbucket repository, optionally filtered by file path.",
source="bitbucket",
surfaces=("investigation", "chat"),
use_cases=[
"Checking whether a recent change could explain a failure",
"Reviewing commit history for a specific file or directory",
],
requires=["repo_slug"],
input_schema={
"type": "object",
"properties": {
"repo_slug": {"type": "string"},
"path": {"type": "string", "default": ""},
"limit": {"type": "integer", "default": 20},
"workspace": {"type": "string"},
"username": {"type": "string"},
"app_password": {"type": "string"},
"base_url": {"type": "string"},
"max_results": {"type": "integer"},
"integration_id": {"type": "string"},
},
"required": ["repo_slug"],
},
is_available=_list_bitbucket_commits_available,
extract_params=_list_bitbucket_commits_extract_params,
)
def list_bitbucket_commits(
repo_slug: str,
workspace: str | None = None,
username: str | None = None,
app_password: str | None = None,
base_url: str | None = None,
max_results: int | None = None,
integration_id: str | None = None,
path: str = "",
limit: int = 20,
**_kwargs: Any,
) -> dict[str, Any]:
"""Fetch recent commits from a Bitbucket repository."""
config = _resolve_config(
workspace,
username,
app_password,
base_url,
max_results,
integration_id,
)
if config is None:
return {
"source": "bitbucket",
"available": False,
"error": "Bitbucket integration is not configured.",
"commits": [],
}
return list_commits(config, repo_slug=repo_slug, path=path, limit=limit)