Skip to content

Commit 5a2d6f5

Browse files
committed
gittest: export members of GitRepo
1 parent 260ebf9 commit 5a2d6f5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

testutil/gittest/gittest.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,15 @@ func Commit(t *testing.T, path, content, msg string) CommitFunc {
259259
},
260260
})
261261
require.NoError(t, err)
262-
_, err = repo.CommitObject(commit)
262+
obj, err := repo.CommitObject(commit)
263263
require.NoError(t, err)
264+
t.Logf("commited object %s", obj.Hash.String())
264265
}
265266
}
266267

267268
type GitRepo struct {
268-
repo *git.Repository
269-
fs billy.Filesystem
269+
Repo *git.Repository
270+
FS billy.Filesystem
270271
}
271272

272273
// NewRepo returns a new Git repository.
@@ -282,22 +283,22 @@ func NewRepo(t *testing.T, fs billy.Filesystem) *GitRepo {
282283
require.NoError(t, err)
283284

284285
return &GitRepo{
285-
repo: repo,
286-
fs: fs,
286+
Repo: repo,
287+
FS: fs,
287288
}
288289
}
289290

290291
func (g *GitRepo) Commit(commits ...CommitFunc) *GitRepo {
291292
for _, commit := range commits {
292-
commit(g.fs, g.repo)
293+
commit(g.FS, g.Repo)
293294
}
294295
return g
295296
}
296297

297298
// WriteFile writes a file to the filesystem.
298299
func WriteFile(t *testing.T, fs billy.Filesystem, path, content string) {
299300
t.Helper()
300-
file, err := fs.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o644)
301+
file, err := fs.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o644)
301302
require.NoError(t, err)
302303
_, err = file.Write([]byte(content))
303304
require.NoError(t, err)

0 commit comments

Comments
 (0)