Bitbucket push webhook handler to generate a list of files changed on a push
Project description
Bitbucket hook diffstat
Overview
Bitbucket push webhook handler to generate a list of files changed on a push.
It processes branch updates, and the branch creates events and extracts the file paths of the files whose content was changed in that event, including the removal or creation of the file itself.
In the case of a branch update event, it gets the changeset between the current HEAD of the branch and the previous HEAD of that branch.
In case the branch is created, it gets the changeset between the current HEAD of the branch and the HEAD of the main branch of the repository.
It uses Bitbucket diffstat
, repositories
, and branches
APIs. It handles some basic retries on unexpected HTTP response codes from BitBucket.
Usage
from bitbucket_hook_diffstat import process_bitbucket_push_events
result, errors = process_bitbucket_push_events(
push_payload, repo_owner, repo_name, bitbucket_user, bitbucket_password
) # This function does not raise any Exception but rather tries to return at least something usefull. Bitbucket will retry up to 2 times more if gets non 200 response.
result # Is a dict of zero or more branches to the set of one or many file pathnames
{'master': {'.gitignore'}}
errors # Is a list of text strings indicating the errors which occured during the process.
[]
# - could be one or more of (with exception message)
# "Invalid push change payload"
# "Unexpected response HTTP status"
# "Can not process event because it's type is "unknown""
# "Unhandled error"
Where bitbucket_password
is an "app password" and bitbucket_user
is available as "Username" in Bitbucket profile settings. This user should be authorized to do Repositories Read.
push_payload
is a Bitbucket repository push event
repo_owner
and repo_name
one can retrieve from the repository URL https://bitbucket.org/repo_owner/repo_name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bitbucket-hook-diffstat-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 015d9e829867b34d5ed57378ae417e41e2435363205d32bf3178b18bba727def |
|
MD5 | bde575ecbb1fe182bb73b661a79b2414 |
|
BLAKE2b-256 | 97e5b32a0efbecf4bee2639c67ee07dc0c5c19f5703f83dd0821e7196b0667d6 |
Hashes for bitbucket_hook_diffstat-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e9c017e140f4a591b0c38a1743e214f87b23a3bb58d38c586e6f3953b0c13c1 |
|
MD5 | e61248f92132d1829cebc1022fa61246 |
|
BLAKE2b-256 | 77861206953419363c8eb0edc8377d8e7204c03148a9b00552456e7f4a16f853 |