zaquestion / lab

Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab
https://zaquestion.github.io/lab
Creative Commons Zero v1.0 Universal
1.11k stars 102 forks source link

Replace `git` with go-git library #700

Open zaquestion opened 3 years ago

zaquestion commented 3 years ago

Multiple reasons to do this, one is speed, running library functions instead of execing git showed noticeable speedups when I experimented with this change over last time. 2nd is that one of the main complaints about lab is that git is a dependency, since we have an opportunity to (almost) completely remove this dep and speedup the tool at the same time we should definitely take it.

Some of the work has already been done on: https://github.com/zaquestion/lab/tree/go-git (this branch is pretty far behind now, so it'd need to be caught up and the work in internal/git completed.

For good measure lets see if we can also record some of the perf improvements on the ticket for posterity, even if it's just "wow x feels faster", I do recall having those moments when I started the branch.

Ref: https://github.com/go-git/go-git

bmeneg commented 3 years ago

+1 for using go-git (do you mean https://github.com/go-git/go-git, right?)! I'm not sure how better/faster it would be, but for sure it seems more suitable than calling git cli directly.

zampierilucas commented 2 years ago

I think we should consider https://github.com/libgit2/git2go, as it is the library that Gitlab/Gitaly uses.

bmeneg commented 2 years ago

Oh, ok, that's interesting. This seems indeed the "officially supported" module for libgit2. However I think the goal of using go-git is to eliminate the need for any system executable/library dependency and since git2go is basically a set of bindings to libgit2 the C library itself is required. Using go-git would allow a single go build to have everything up and running and I think go-git has everything we need for now (even though it's known it lacks a bunch of git-core features).

I'll keep this in mind in case I face a case where go-git doesn't offer an alternative.