clean-bitbucket
A small library meant to be used for cleaning out unused bitbucket branches.
Installation
Install with npm install -g clean-bitbucket
.
Create a .env
file with your bitbucket URL and token (it needs to be a write token to be able to delete
branches) in the working directory:
BITBUCKET_URL=https://bitbucket-server.somewhere.com/
BITBUCKET_TOKEN=[token]
Of course, you can also export them to the environment before running the script:
export BITBUCKET_URL=https://bitbucket-server.somewhere.com/
export BITBUCKET_TOKEN=[token]
Or add them directly in front of the command:
BITBUCKET_URL=https://bitbucket-server.somewhere.com/ BITBUCKET_TOKEN=[token] clean-bitbucket [group] [repository] [baseBranch]
Usage
After that, you'll be able to run clean-bitbucket [group] [repository] [baseBranch]
to get a list of all the branches
in the repo and how they differ from the branch specified as base.
Every branch will show how many commits are added/missing from the branch relative to the base.
If there are zero commits missing from the base branch, the branch will be marked as MERGED
.
Branches with the keywords develop
or release
in them will be locked, and cannot be deleted.
Shortcuts that are available are:
-
d
: delete the currently highlighted branch (press again to confirm) -
q
: exit the program -
r
: reload the current page (useful after deleting branches) -
m
: delete all branches marked as merged (excluding locked branches) -
up
/down
: move one item up or down -
left
/right
: go to the next/previous page -
pageup
/pagedown
: move 25 items up or down