Skip to content

Commit 93a6231

Browse files
authored
Merge pull request #1145 from fluxcd/bump-gogit
Update go-git to unreleased v5.8.0
2 parents c09e25b + 995cab5 commit 93a6231

File tree

3 files changed

+56
-58
lines changed

3 files changed

+56
-58
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ replace github.com/opencontainers/go-digest => github.com/opencontainers/go-dige
1414
// Check again when oras.land/oras-go is updated, which is a dependency of Helm.
1515
replace github.com/docker/docker => github.com/docker/docker v23.0.6+incompatible
1616

17+
// Replace go-git to unreleased v5.8.0 to improve support for Git v2.41+.
18+
replace github.com/go-git/go-git/v5 => github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01
19+
1720
require (
1821
cloud.google.com/go/storage v1.30.1
1922
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmS
437437
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
438438
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
439439
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8=
440-
github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE=
441-
github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8=
440+
github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01 h1:+yTyIn80JO1XGuLjgnUwnJDFpRw5dOVk6Yv5dAzi5dI=
441+
github.com/go-git/go-git/v5 v5.7.1-0.20230702134234-dd4e2b7f4b01/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8=
442442
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
443443
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
444444
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=

internal/controller/gitrepository_controller_test.go

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -219,62 +219,57 @@ func TestGitRepositoryReconciler_Reconcile(t *testing.T) {
219219
testSuspendedObjectDeleteWithArtifact(ctx, g, obj)
220220
}
221221

222-
// TODO(hidde): Re-enable this test.
223-
// It is currently disabled because it fails on machines with Git version
224-
// >=v2.41.0 due to changes to commands used by the test server. Causing
225-
// the test server to return an error when cloning an empty repository,
226-
// instead of yielding an empty object.
227-
//func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
228-
// g := NewWithT(t)
229-
//
230-
// server, err := gittestserver.NewTempGitServer()
231-
// g.Expect(err).NotTo(HaveOccurred())
232-
// defer os.RemoveAll(server.Root())
233-
// server.AutoCreate()
234-
// g.Expect(server.StartHTTP()).To(Succeed())
235-
// defer server.StopHTTP()
236-
//
237-
// obj := &sourcev1.GitRepository{
238-
// ObjectMeta: metav1.ObjectMeta{
239-
// GenerateName: "empty-",
240-
// Generation: 1,
241-
// },
242-
// Spec: sourcev1.GitRepositorySpec{
243-
// Interval: metav1.Duration{Duration: interval},
244-
// Timeout: &metav1.Duration{Duration: timeout},
245-
// URL: server.HTTPAddress() + "/test.git",
246-
// },
247-
// }
248-
//
249-
// clientBuilder := fakeclient.NewClientBuilder().
250-
// WithScheme(testEnv.GetScheme()).
251-
// WithStatusSubresource(&sourcev1.GitRepository{})
252-
//
253-
// r := &GitRepositoryReconciler{
254-
// Client: clientBuilder.Build(),
255-
// EventRecorder: record.NewFakeRecorder(32),
256-
// Storage: testStorage,
257-
// patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
258-
// }
259-
//
260-
// g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
261-
// defer func() {
262-
// g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
263-
// }()
264-
//
265-
// var commit git.Commit
266-
// var includes artifactSet
267-
// sp := patch.NewSerialPatcher(obj, r.Client)
268-
//
269-
// got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
270-
// assertConditions := []metav1.Condition{
271-
// *conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
272-
// }
273-
// g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
274-
// g.Expect(err).To(HaveOccurred())
275-
// g.Expect(got).To(Equal(sreconcile.ResultEmpty))
276-
// g.Expect(commit).ToNot(BeNil())
277-
//}
222+
func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
223+
g := NewWithT(t)
224+
225+
server, err := gittestserver.NewTempGitServer()
226+
g.Expect(err).NotTo(HaveOccurred())
227+
defer os.RemoveAll(server.Root())
228+
server.AutoCreate()
229+
g.Expect(server.StartHTTP()).To(Succeed())
230+
defer server.StopHTTP()
231+
232+
obj := &sourcev1.GitRepository{
233+
ObjectMeta: metav1.ObjectMeta{
234+
GenerateName: "empty-",
235+
Generation: 1,
236+
},
237+
Spec: sourcev1.GitRepositorySpec{
238+
Interval: metav1.Duration{Duration: interval},
239+
Timeout: &metav1.Duration{Duration: timeout},
240+
URL: server.HTTPAddress() + "/test.git",
241+
},
242+
}
243+
244+
clientBuilder := fakeclient.NewClientBuilder().
245+
WithScheme(testEnv.GetScheme()).
246+
WithStatusSubresource(&sourcev1.GitRepository{})
247+
248+
r := &GitRepositoryReconciler{
249+
Client: clientBuilder.Build(),
250+
EventRecorder: record.NewFakeRecorder(32),
251+
Storage: testStorage,
252+
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
253+
}
254+
255+
g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
256+
defer func() {
257+
g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
258+
}()
259+
260+
var commit git.Commit
261+
var includes artifactSet
262+
sp := patch.NewSerialPatcher(obj, r.Client)
263+
264+
got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
265+
assertConditions := []metav1.Condition{
266+
*conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
267+
}
268+
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
269+
g.Expect(err).To(HaveOccurred())
270+
g.Expect(got).To(Equal(sreconcile.ResultEmpty))
271+
g.Expect(commit).ToNot(BeNil())
272+
}
278273

279274
func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
280275
type options struct {

0 commit comments

Comments
 (0)