Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libgit2 support #82

Merged
merged 7 commits into from
Jan 14, 2021
Merged

Libgit2 support #82

merged 7 commits into from
Jan 14, 2021

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Jan 12, 2021

This adds support for switching to libgit2 for clone and push, for the same reason source-controller needs that option.

Fix: #71

@squaremo squaremo force-pushed the libgit2-support branch 2 times, most recently from 73163c1 to dc43eb9 Compare January 12, 2021 14:04
@squaremo squaremo force-pushed the libgit2-support branch 6 times, most recently from 3a0f3a5 to d1fa10f Compare January 12, 2021 17:22
@squaremo squaremo marked this pull request as ready for review January 12, 2021 18:02
README.md Outdated Show resolved Hide resolved
@squaremo squaremo force-pushed the libgit2-support branch 2 times, most recently from 847f1a4 to a0ffd98 Compare January 13, 2021 10:57
This updates the source controller module to v0.5.2, and adjusts the
use of the git package therein. The main change there is that it now
accounts for two different git implementations -- go-git and libgit2
-- but I have not exposed that difference, just made it work as it did
before.

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit changes the clone and push code to use libgit2. In the
case of clone, this means simply passing the const representing the
libgit2 implementation to the source-controller/pkg/git function. In
the case of push, this means adding a small helper to do the required
invocation.

NB:

 - there's no need to use libgit2 for operations other than clone and
   push; in particular, commits can have a single, go-git
   implementation.

 - libgit2's push is quite sensitive to the refspec it's given;
   `<branch>:refs/heads/<branch>` didn't work, and supplying no
   refspecs makes it time out.

 - libgit2 push will only work with a repository on disk that was
   cloned by libgit2 -- it's initialising the repo differently to
   go-git. This is surprising (a git repo is a git repo, isn't it?),
   but fine -- any given automation will use _either_ go-git or
   libgit2 for both of clone and push.

Signed-off-by: Michael Bridgen <michael@weave.works>
This copies the approach used in source-controller: add the
libgit2-dev package (i.e., headers) to the build container, then add
the shared lib to the _image_ image.

Signed-off-by: Michael Bridgen <michael@weave.works>
This separates the commit and push steps, since the commit step just
uses gogit, while the push step will dispatch based on the git
implementation.

Signed-off-by: Michael Bridgen <michael@weave.works>
This follows up the stage-setting in prior commits, by respecting the
GitImplementation field given in the GitRepository object. NB it only
matters for cloning and pushing, so gogit is used in the "middle" to
record the commit in the local checkout.

Signed-off-by: Michael Bridgen <michael@weave.works>
The build now incorporates libgit2; however, most Linux distributions,
notably Ubuntu and Debian, have a version of libgit2 that's over a
year old. This copies the approach used in source-controller, which is
to use a container image that can be preloaded with an up to date
release of libgit2.

Signed-off-by: Michael Bridgen <michael@weave.works>
Signed-off-by: Michael Bridgen <michael@weave.works>
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I touched the PR myself so maybe @stefanprodan should have a look too.

Thank you @squaremo 🍇

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @squaremo 🍻

@squaremo squaremo merged commit 30d3ef7 into main Jan 14, 2021
@squaremo squaremo deleted the libgit2-support branch January 14, 2021 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add implementation of libgit2 (Follow configuration from source-controller)
3 participants