diff --git a/controllers/gitrepository_controller_test.go b/controllers/gitrepository_controller_test.go index 462325475..f2fd6295d 100644 --- a/controllers/gitrepository_controller_test.go +++ b/controllers/gitrepository_controller_test.go @@ -383,7 +383,7 @@ var _ = Describe("GitRepositoryReconciler", func() { reference: &sourcev1.GitRepositoryRef{Branch: "main"}, waitForReason: sourcev1.GitOperationFailedReason, expectStatus: metav1.ConditionFalse, - expectMessage: "error: user rejected certificate", + expectMessage: "unable to clone: user rejected certificate", gitImplementation: sourcev1.LibGit2Implementation, }), Entry("self signed libgit2 with CA", refTestCase{ diff --git a/pkg/git/gogit/checkout.go b/pkg/git/gogit/checkout.go index 14f1ecfb9..1777d30fa 100644 --- a/pkg/git/gogit/checkout.go +++ b/pkg/git/gogit/checkout.go @@ -79,7 +79,7 @@ func (c *CheckoutBranch) Checkout(ctx context.Context, path, url string, opts *g CABundle: caBundle(opts), }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.GoGitError(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.GoGitError(err)) } head, err := repo.Head() if err != nil { @@ -117,7 +117,7 @@ func (c *CheckoutTag) Checkout(ctx context.Context, path, url string, opts *git. CABundle: caBundle(opts), }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.GoGitError(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.GoGitError(err)) } head, err := repo.Head() if err != nil { @@ -158,7 +158,7 @@ func (c *CheckoutCommit) Checkout(ctx context.Context, path, url string, opts *g } repo, err := extgogit.PlainCloneContext(ctx, path, false, cloneOpts) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.GoGitError(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.GoGitError(err)) } w, err := repo.Worktree() if err != nil { @@ -206,7 +206,7 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, opts *g CABundle: caBundle(opts), }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, err) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.GoGitError(err)) } repoTags, err := repo.Tags() diff --git a/pkg/git/gogit/checkout_test.go b/pkg/git/gogit/checkout_test.go index 37367852b..946dd9c5d 100644 --- a/pkg/git/gogit/checkout_test.go +++ b/pkg/git/gogit/checkout_test.go @@ -126,7 +126,7 @@ func TestCheckoutTag_Checkout(t *testing.T) { name: "Non existing tag", tag: "tag-1", checkoutTag: "invalid", - expectErr: "error: couldn't find remote ref \"refs/tags/invalid\"", + expectErr: "couldn't find remote ref \"refs/tags/invalid\"", }, } for _, tt := range tests { diff --git a/pkg/git/libgit2/checkout.go b/pkg/git/libgit2/checkout.go index dbf0b4033..8e3d36a75 100644 --- a/pkg/git/libgit2/checkout.go +++ b/pkg/git/libgit2/checkout.go @@ -68,7 +68,7 @@ func (c *CheckoutBranch) Checkout(ctx context.Context, path, url string, opts *g CheckoutBranch: c.Branch, }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.LibGit2Error(err)) + return nil, fmt.Errorf("unable to clone: %w", gitutil.LibGit2Error(err)) } defer repo.Free() head, err := repo.Head() @@ -96,7 +96,7 @@ func (c *CheckoutTag) Checkout(ctx context.Context, path, url string, opts *git. }, }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.LibGit2Error(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.LibGit2Error(err)) } defer repo.Free() cc, err := checkoutDetachedDwim(repo, c.Tag) @@ -119,7 +119,7 @@ func (c *CheckoutCommit) Checkout(ctx context.Context, path, url string, opts *g }, }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.LibGit2Error(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.LibGit2Error(err)) } defer repo.Free() oid, err := git2go.NewOid(c.Commit) @@ -150,7 +150,7 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, opts *g }, }) if err != nil { - return nil, fmt.Errorf("unable to clone '%s', error: %w", url, gitutil.LibGit2Error(err)) + return nil, fmt.Errorf("unable to clone '%s': %w", url, gitutil.LibGit2Error(err)) } defer repo.Free()