Skip to content

Commit 95ff02d

Browse files
Fix panic on nil error in defaultToCurrentGitRepo (#1514)
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent fe0e040 commit 95ff02d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/framework/git_helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ func defaultToCurrentGitRepo(input *FleetCreateGitRepoInput) {
163163

164164
// Open the current repository
165165
repo, err := git.PlainOpen(cmp.Or(os.Getenv("ROOT_DIR"), "."))
166-
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to open git repo: %s", err.Error()))
166+
Expect(err).ShouldNot(HaveOccurred(), fmt.Errorf("failed to open git repo: %w", err).Error())
167167

168168
// Get remote repository URL
169169
remotes, err := repo.Remotes()
170-
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to get remotes: %s", err.Error()))
170+
Expect(err).ShouldNot(HaveOccurred(), fmt.Errorf("failed to get remotes: %w", err).Error())
171171

172172
// Find origin remote
173173
for _, remote := range remotes {
@@ -185,7 +185,7 @@ func defaultToCurrentGitRepo(input *FleetCreateGitRepoInput) {
185185

186186
// Get the current branch
187187
head, err := repo.Head()
188-
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to get HEAD: %s", err.Error()))
188+
Expect(err).ShouldNot(HaveOccurred(), fmt.Errorf("failed to get HEAD: %w", err).Error())
189189

190190
input.Branch = head.Name().Short()
191191

0 commit comments

Comments
 (0)