/polly-merge

🦜bitbucket merge poll utility

Primary LanguagePythonThe UnlicenseUnlicense

🦜 polly-merge

License: Unlicense Code style: black GitHub Workflow Status LGTM

Polls your open pull requests on Bitbucket server, and attempts to merge any pull requests that have a comment/description containing @polly <COMMAND> (configurable).

NOTE: this is for use with the Bitbucket Server 1.0 REST API, it won't work with Bitbucket Cloud (which disabled the 1.0 API a while back).

You might for example run it as a cron job, to background merge your pr's instead of having to visit the bitbucket ui periodically.

It's kindof like a really bad version of one small piece of the bors-ng idea, running on a local machine and polling instead of a reasonable system design 😖 .

Commands

@polly merge

Attempts to merge the PR.

@polly merge-after <pr url>

Attempts to merge the PR only after the given PR has been merged, ex:

@polly merge-after https://bitbucket-server.com/projects/PROJ/repos/some-repo/pull-requests/1234

Usage

Requires python3 to be installed.

You might set this up to be run with cron, eg:

# grab this repo
git clone https://github.com/noahp/polly-merge.git ~/polly-merge

Then add the below entry to crontab, eg run crontab -e:

# set your token + url into the environment vars
POLLY_MERGE_BITBUCKET_API_TOKEN=<your token>
POLLY_MERGE_BITBUCKET_URL=<your url>

# defaults to "@polly merge"
POLLY_MERGE_TRIGGER_COMMENT=<your trigger comment>

# if provided, comments from any user can trigger the action,
# instead of just the authenticated user
POLLY_MERGE_ANY_USER_COMMENT=<1 to enable, or unset to disable>

# if POLLY_MERGE_LOG_FILE is unset, defaults to stdout
POLLY_MERGE_LOG_FILE=<your log file location>
*/5 * * * * ~/polly-merge/polly-merge.py

Todo

Work in progress, remaining stuff:

  • maybe rework configuration to be a little less lame (list of params?)
  • add fake bitbucket server api 1.0

This should probably not be python but I'm reallllly lazy.

Keeping it dependency free at least so it has a chance of running on someone's system.

Developing

You can run whatever tests CI runs by executing the ./test.sh script (requires Docker; everything runs in a container).