Changeset View
Changeset View
Standalone View
Standalone View
swh/web/save_origin_webhooks/bitbucket.py
Show All 22 Lines | def is_forge_request(self, request: Request) -> bool: | ||||
f"{self.FORGE_TYPE}-Webhooks/" | f"{self.FORGE_TYPE}-Webhooks/" | ||||
) | ) | ||||
and "X-Event-Key" in request.headers | and "X-Event-Key" in request.headers | ||||
) | ) | ||||
def is_push_event(self, request: Request) -> bool: | def is_push_event(self, request: Request) -> bool: | ||||
return request.headers["X-Event-Key"] == "repo:push" | return request.headers["X-Event-Key"] == "repo:push" | ||||
def extract_repo_url_and_visit_type(self, request: Request) -> Tuple[str, str]: | def extract_repo_info(self, request: Request) -> Tuple[str, str, bool]: | ||||
repo_url = ( | repo_url = ( | ||||
request.data.get("repository", {}) | request.data.get("repository", {}) | ||||
.get("links", {}) | .get("links", {}) | ||||
.get("html", {}) | .get("html", {}) | ||||
.get("href", "") | .get("href", "") | ||||
) | ) | ||||
if repo_url: | if repo_url: | ||||
repo_url += ".git" | repo_url += ".git" | ||||
return repo_url, "git" | private = request.data.get("repository", {}).get("is_private", False) | ||||
return repo_url, "git", private | |||||
api_origin_save_webhook_bitbucket = BitbucketOriginSaveWebhookReceiver() | api_origin_save_webhook_bitbucket = BitbucketOriginSaveWebhookReceiver() |