Skip to content

Commit 121577c

Browse files
author
Paulo Gomes
authored
Merge pull request #321 from pjbgf/libgit2-130
Update libgit2 to 1.3.0
2 parents 0f456fa + d20cdb5 commit 121577c

File tree

9 files changed

+382
-103
lines changed

9 files changed

+382
-103
lines changed

ATTRIBUTIONS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,18 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
12031203
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
12041204
OF THE POSSIBILITY OF SUCH DAMAGE.
12051205

1206+
----------------------------------------------------------------------
1207+
1208+
The xoroshiro256** implementation is licensed in the public domain:
1209+
1210+
Written in 2018 by David Blackman and Sebastiano Vigna ([email protected])
1211+
1212+
To the extent possible under law, the author has dedicated all copyright
1213+
and related and neighboring rights to this software to the public domain
1214+
worldwide. This software is distributed without any warranty.
1215+
1216+
See <http://creativecommons.org/publicdomain/zero/1.0/>.
1217+
12061218
***
12071219

12081220
## zlib

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG GO_VERSION=1.17
33
ARG XX_VERSION=1.1.0
44

55
ARG LIBGIT2_IMG=ghcr.io/fluxcd/golang-with-libgit2
6-
ARG LIBGIT2_TAG=libgit2-1.1.1-7
6+
ARG LIBGIT2_TAG=libgit2-1.3.0-2
77

88
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} AS libgit2-libs
99

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CRD_OPTIONS ?= crd:crdVersions=v1
88

99
# Base image used to build the Go binary
1010
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
11-
LIBGIT2_TAG ?= libgit2-1.1.1-7
11+
LIBGIT2_TAG ?= libgit2-1.3.0-2
1212

1313
# Allows for defining additional Docker buildx arguments,
1414
# e.g. '--push'.
@@ -144,8 +144,7 @@ test-api: ## Run api tests
144144
cd api; go test ./... -coverprofile cover.out
145145

146146
manager: $(LIBGIT2) generate fmt vet ## Build manager binary
147-
go run ./main.go
148-
147+
go build ./main.go
149148

150149
run: $(LIBGIT2) generate fmt vet manifests # Run against the configured Kubernetes cluster in ~/.kube/config
151150
go run $(GO_STATIC_FLAGS) ./main.go --log-level=${LOG_LEVEL} --log-encoding=console
@@ -272,6 +271,19 @@ update-attributions:
272271
./hack/update-attributions.sh
273272

274273
verify: update-attributions fmt
274+
ifneq ($(shell grep -o 'LIBGIT2_IMG ?= \w.*' Makefile | cut -d ' ' -f 3):$(shell grep -o 'LIBGIT2_TAG ?= \w.*' Makefile | cut -d ' ' -f 3), \
275+
$(shell grep -o "LIBGIT2_IMG=\w.*" Dockerfile | cut -d'=' -f2):$(shell grep -o "LIBGIT2_TAG=\w.*" Dockerfile | cut -d'=' -f2))
276+
@{ \
277+
echo "LIBGIT2_IMG and LIBGIT2_TAG must match in both Makefile and Dockerfile"; \
278+
exit 1; \
279+
}
280+
endif
281+
ifneq ($(shell grep -o 'LIBGIT2_TAG ?= \w.*' Makefile | cut -d ' ' -f 3), $(shell grep -o "LIBGIT2_TAG=.*" tests/fuzz/oss_fuzz_build.sh | sed 's;LIBGIT2_TAG="$${LIBGIT2_TAG:-;;g' | sed 's;}";;g'))
282+
@{ \
283+
echo "LIBGIT2_TAG must match in both Makefile and tests/fuzz/oss_fuzz_build.sh"; \
284+
exit 1; \
285+
}
286+
endif
275287
ifneq (, $(shell git status --porcelain --untracked-files=no))
276288
@{ \
277289
echo "working directory is dirty:"; \

controllers/git_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package controllers
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"testing"
89
"time"
910

1011
"github.com/go-git/go-billy/v5/memfs"
1112
gogit "github.com/go-git/go-git/v5"
12-
"github.com/go-git/go-git/v5/plumbing"
1313
"github.com/go-git/go-git/v5/plumbing/object"
1414
"github.com/go-git/go-git/v5/storage/memory"
1515
"github.com/go-logr/logr"
@@ -144,18 +144,11 @@ func TestPushRejected(t *testing.T) {
144144
t.Fatal(err)
145145
}
146146

147-
tmp, err := os.MkdirTemp("", "gotest-imageauto-git")
148-
if err != nil {
149-
t.Fatal(err)
150-
}
151-
repoURL := gitServer.HTTPAddress() + "/appconfig.git"
152-
repo, err := gogit.PlainClone(tmp, false, &gogit.CloneOptions{
153-
URL: repoURL,
154-
ReferenceName: plumbing.NewBranchReferenceName("main"),
155-
})
147+
repoURL := gitServer.HTTPAddressWithCredentials() + "/appconfig.git"
148+
repo, err := clone(repoURL, "origin", "main")
156149

157150
// This is here to guard against push in general being broken
158-
err = push(context.TODO(), tmp, "main", repoAccess{
151+
err = push(context.TODO(), repo.Workdir(), "main", repoAccess{
159152
url: repoURL,
160153
auth: nil,
161154
})
@@ -164,13 +157,13 @@ func TestPushRejected(t *testing.T) {
164157
}
165158

166159
// This is not under test, but needed for the next bit
167-
if err = switchBranch(repo, branch); err != nil {
160+
if err = repo.SetHead(fmt.Sprintf("refs/heads/%s", branch)); err != nil {
168161
t.Fatal(err)
169162
}
170163

171164
// This is supposed to fail, because the hook rejects the branch
172165
// pushed to.
173-
err = push(context.TODO(), tmp, branch, repoAccess{
166+
err = push(context.TODO(), repo.Workdir(), branch, repoAccess{
174167
url: repoURL,
175168
auth: nil,
176169
})

controllers/imageupdateautomation_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
"github.com/Masterminds/sprig/v3"
3232
gogit "github.com/go-git/go-git/v5"
33-
libgit2 "github.com/libgit2/git2go/v31"
33+
libgit2 "github.com/libgit2/git2go/v33"
3434

3535
"github.com/ProtonMail/go-crypto/openpgp"
3636
securejoin "github.com/cyphar/filepath-securejoin"
@@ -702,11 +702,11 @@ func push(ctx context.Context, path, branch string, access repoAccess) error {
702702
// calling repo.Push will succeed even if a reference update is
703703
// rejected; to detect this case, this callback is supplied.
704704
var callbackErr error
705-
callbacks.PushUpdateReferenceCallback = func(refname, status string) libgit2.ErrorCode {
705+
callbacks.PushUpdateReferenceCallback = func(refname, status string) error {
706706
if status != "" {
707707
callbackErr = fmt.Errorf("ref %s rejected: %s", refname, status)
708708
}
709-
return libgit2.ErrorCodeOK
709+
return nil
710710
}
711711
err = origin.Push([]string{fmt.Sprintf("refs/heads/%s:refs/heads/%s", branch, branch)}, &libgit2.PushOptions{
712712
RemoteCallbacks: callbacks,

0 commit comments

Comments
 (0)