go-vcs is a library for manipulating and inspecting VCS repositories in Go. It currently supports Git and Mercurial (hg).
Note: the public API is experimental and subject to change until further notice.
The faster libgit2 implementation of git depends on git2go
on its next
branch. To install it, you will need:
cmake
pkg-config
libssh2
libgcrypt
Once you have those prerequisites, follow these steps to install git2go
on next
branch.
For hg blame, you need to install hglib: pip install python-hglib
.
go get -u sourcegraph.com/sourcegraph/go-vcs/vcs
The goal is to have all supported backends at feature parity, but until then, consult this table for implementation differences.
Feature | git | gitcmd | hg | hgcmd |
---|---|---|---|---|
vcs.CommitsOptions.Path | ⬜ | ✅ | ⬜ | ⬜ |
vcs.BranchesOptions.MergedInto | ⬜ | ✅ | ⬜ | ⬜ |
vcs.BranchesOptions.IncludeCommit | ⬜ | ✅ | ⬜ | ⬜ |
vcs.BranchesOptions.BehindAheadBranch | ⬜ | ✅ | ⬜ | ⬜ |
vcs.Repository.Committers | ⬜ | ✅ | ⬜ | ⬜ |
vcs.FileLister | ⬜ | ✅ | ⬜ | ⬜ |
vcs.UpdateResult | ⬜ | ✅ | ⬜ | ⬜ |
Contributions that fill in the gaps are welcome!
You need to install and run the protobuf compiler before you can regenerate Go code after you change the vcs.proto
file.
-
Install protoc, the protobuf compiler. Find more details in the protobuf README.
On OS X, you can install it with Homebrew by running:
brew install --devel protobuf
Then make sure the
protoc
binary is in your$PATH
. -
Install gogo/protobuf.
go get -u github.com/gogo/protobuf/...
-
Install
gopathexec
:go get -u sourcegraph.com/sourcegraph/gopathexec
go generate sourcegraph.com/sourcegraph/go-vcs/vcs/...
Run go test ./vcs/...
. You may need to supply linker flags to link with libgit2. If you get a linker error, try running make test
instead. If that doesn't work, check the command that make test
runs to see if it is using the correct paths on your system.
Note that the tests test the libgit2 implementation and SSH support (see above instructions).
- Quinn Slack sqs@sourcegraph.com
See all contributors here.