1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-16 11:37:01 +02:00
lazygit/vendor/github.com/tcnksm/go-gitconfig
2019-09-01 21:24:03 +10:00
..
.gitignore switch to Go modules 2019-09-01 21:24:03 +10:00
CHANGELOG.md switch to Go modules 2019-09-01 21:24:03 +10:00
gitconfig.go add git config check and editing ability 2018-08-08 20:45:12 +10:00
LICENSE add git config check and editing ability 2018-08-08 20:45:12 +10:00
README.md switch to Go modules 2019-09-01 21:24:03 +10:00
wercker.yml switch to Go modules 2019-09-01 21:24:03 +10:00

go-gitconfig

GitHub release Wercker Coveralls MIT License Go Documentation

go-gitconfig is a pacakge to use gitconfig values in Golang.

Sometimes you want to extract username or its email address implicitly in your tool. Now most of developer use git, so we can use its configuration variables. go-gitconfig is for that.

go-gitconfig is very small, so it may not be included what you want to use. If you want to use more git specific variable, check Other.

Usage

If you want to use git user name defined in ~/.gitconfig:

username, err := gitconfig.Username()

Or git user email defined in ~/.gitconfig:

email, err := gitconfig.Email()

Or, if you want to extract origin url of current project (from .git/config):

url, err := gitconfig.OriginURL()

You can also extract value by key:

editor, err := gitconfig.Global("core.editor")
remote, err := gitconfig.Local("branch.master.remote")

See more details in document at https://godoc.org/github.com/tcnksm/go-gitconfig.

Install

To install, use go get:

$ go get -d github.com/tcnksm/go-gitconfig

VS.

These packages have many features to use git from golang. go-gitconfig is very simple alternative and focus to extract information from gitconfig. go-gitconfig is used in tcnksm/ghr.

Contribution

  1. Fork (https://github.com/tcnksm/go-gitconfig/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 new Pull Request

Author

tcnksm