Buranko is a CLI tool for parsing and formatting Git branch names.
- Git branch name parsing
- Output formatting using templates
- Field extraction
Download a binary from releases page and place it in $PATH
directory.
Display the current branch ID:
buranko
Format the output using a configured template:
buranko --template
Template configuration:
git config buranko.template "{Action}/{ID}-{Description}"
Available template variables:
{FullName}
: Full branch name{Action}
: Action (feature, bugfix, etc.){ID}
: Branch ID{LinkID}
: Link ID (with #){Description}
: Branch description
This option is useful for referencing issues in other GitHub repositories, or for software that requires a prefix in the issue number.
$ git checkout -b feature/1234_foo-bar
$ git config buranko.template ABC-{ID}
$ buranko --template
ABC-1234
$ git config buranko.template foo-org/bar-repo#{ID}
$ buranko --template
foo-org/bar-repo#1234
Output only a specific field:
buranko --output FullName
Available fields:
FullName
: Full branch nameAction
: ActionID
: Branch IDLinkID
: Link IDDescription
: Branch description
Display all branch information:
buranko --verbose
You can read branch names from stdin:
echo "feature/123-test" | buranko
Buranko parses branch names in the following format:
<action>/<id>-<description>
Examples:
feature/123-add-login
bugfix/456-fix-crash
hotfix/789-security-patch
More patterns at main.rs
.
Add an issue ID to the commit message using a git hook.
[Git repository]/.git/hooks/prepare-commit-msg
if [ "$2" == "" ]; then
mv $1 $1.tmp
echo `buranko -output LinkID -template` > $1
cat $1.tmp >> $1
fi