A tool for parse a git branch name
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
Makefile
README.md
branch.go
git.go
input.go
main.go
parser.go
parser_test.go

README.md

buranko

Build Status

A tool for parse a git branch name

Usage

buranko prints the id field by default.

$ git checkout -b feature/1234_foo-bar
$ buranko
1234
$ buranko -ref
#1234

Specify an output field.

$ buranko -output Name
foo-bar

Parse a branch name from stdin.

$ echo 'feature/1234_foo-bar' | buranko
1234

Configuration

Configuration uses 'git-config' variables.

buranko.reponame

A repository name. To output a repository name, use -reponame option.

This is useful for commit across the GitHub repository.

$ git config buranko.reponame foo-org/bar-repo
$ git checkout -b feature/1234_foo-bar
$ buranko -ref -reponame
foo-org/bar-repo#1234

Fields

  • FullName: Full branch name
  • Action: Action type
  • Id: Issue id
  • Name: Name

Parse patterns

feature/1234_foo-bar

  • FullName: feature/1234_foo-bar
  • Action: feature
  • Id: 1234
  • Name: foo-bar

foo-bar

  • FullName: foo-bar
  • Name: foo-bar

More patterns at parser_test.go.

Integrate with prepare-commit-msg

Add an issue id to commit comment using git hook.

GIT-REPO/.git/hooks/prepare-commit-msg

if [ "$2" == "" ]; then
    mv $1 $1.tmp
    echo `buranko -ref -reponame` > $1
    cat $1.tmp >> $1
fi

Install

To install, use go get:

$ go get github.com/chocoby/buranko

Or you can download a binary from releases page and place it in $PATH directory.

Contribution

  1. Fork (https://github.com/chocoby/buranko/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

License

MIT License

Author

Kenta Okamoto