Merge pull request #1145 from fluxcd/bump-gogit

Update go-git to unreleased v5.8.0
This commit is contained in:
Hidde Beydals 2023-07-03 12:37:12 +02:00 committed by GitHub
commit 93a6231c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 58 deletions

3
go.mod
View File

@ -14,6 +14,9 @@ replace github.com/opencontainers/go-digest => github.com/opencontainers/go-dige
// Check again when oras.land/oras-go is updated, which is a dependency of Helm.
replace github.com/docker/docker => github.com/docker/docker v23.0.6+incompatible
// Replace go-git to unreleased v5.8.0 to improve support for Git v2.41+.
replace github.com/go-git/go-git/v5 => github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01
require (
cloud.google.com/go/storage v1.30.1
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1

4
go.sum
View File

@ -437,8 +437,8 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmS
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8=
github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE=
github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8=
github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01 h1:+yTyIn80JO1XGuLjgnUwnJDFpRw5dOVk6Yv5dAzi5dI=
github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=

View File

@ -219,62 +219,57 @@ func TestGitRepositoryReconciler_Reconcile(t *testing.T) {
testSuspendedObjectDeleteWithArtifact(ctx, g, obj)
}
// TODO(hidde): Re-enable this test.
// It is currently disabled because it fails on machines with Git version
// >=v2.41.0 due to changes to commands used by the test server. Causing
// the test server to return an error when cloning an empty repository,
// instead of yielding an empty object.
//func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
// g := NewWithT(t)
//
// server, err := gittestserver.NewTempGitServer()
// g.Expect(err).NotTo(HaveOccurred())
// defer os.RemoveAll(server.Root())
// server.AutoCreate()
// g.Expect(server.StartHTTP()).To(Succeed())
// defer server.StopHTTP()
//
// obj := &sourcev1.GitRepository{
// ObjectMeta: metav1.ObjectMeta{
// GenerateName: "empty-",
// Generation: 1,
// },
// Spec: sourcev1.GitRepositorySpec{
// Interval: metav1.Duration{Duration: interval},
// Timeout: &metav1.Duration{Duration: timeout},
// URL: server.HTTPAddress() + "/test.git",
// },
// }
//
// clientBuilder := fakeclient.NewClientBuilder().
// WithScheme(testEnv.GetScheme()).
// WithStatusSubresource(&sourcev1.GitRepository{})
//
// r := &GitRepositoryReconciler{
// Client: clientBuilder.Build(),
// EventRecorder: record.NewFakeRecorder(32),
// Storage: testStorage,
// patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
// }
//
// g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
// defer func() {
// g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
// }()
//
// var commit git.Commit
// var includes artifactSet
// sp := patch.NewSerialPatcher(obj, r.Client)
//
// got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
// assertConditions := []metav1.Condition{
// *conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
// }
// g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
// g.Expect(err).To(HaveOccurred())
// g.Expect(got).To(Equal(sreconcile.ResultEmpty))
// g.Expect(commit).ToNot(BeNil())
//}
func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
g := NewWithT(t)
server, err := gittestserver.NewTempGitServer()
g.Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(server.Root())
server.AutoCreate()
g.Expect(server.StartHTTP()).To(Succeed())
defer server.StopHTTP()
obj := &sourcev1.GitRepository{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "empty-",
Generation: 1,
},
Spec: sourcev1.GitRepositorySpec{
Interval: metav1.Duration{Duration: interval},
Timeout: &metav1.Duration{Duration: timeout},
URL: server.HTTPAddress() + "/test.git",
},
}
clientBuilder := fakeclient.NewClientBuilder().
WithScheme(testEnv.GetScheme()).
WithStatusSubresource(&sourcev1.GitRepository{})
r := &GitRepositoryReconciler{
Client: clientBuilder.Build(),
EventRecorder: record.NewFakeRecorder(32),
Storage: testStorage,
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
}
g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
defer func() {
g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
}()
var commit git.Commit
var includes artifactSet
sp := patch.NewSerialPatcher(obj, r.Client)
got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
assertConditions := []metav1.Condition{
*conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
}
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
g.Expect(err).To(HaveOccurred())
g.Expect(got).To(Equal(sreconcile.ResultEmpty))
g.Expect(commit).ToNot(BeNil())
}
func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
type options struct {