MCPcopy
hub / github.com/go-git/go-git / NewRepository

Method NewRepository

common_test.go:50–72  ·  view source on GitHub ↗

NewRepository returns a new repository using the .git folder, if the fixture is tagged as worktree the filesystem from fixture is used, otherwise a new memfs filesystem is used as worktree.

(f *fixtures.Fixture)

Source from the content-addressed store, hash-verified

48// is tagged as worktree the filesystem from fixture is used, otherwise a new
49// memfs filesystem is used as worktree.
50func (s *BaseSuite) NewRepository(f *fixtures.Fixture) *Repository {
51 var worktree, dotgit billy.Filesystem
52 if f.Is("worktree") {
53 r, err := PlainOpen(f.Worktree().Root())
54 if err != nil {
55 panic(err)
56 }
57
58 return r
59 }
60
61 dotgit = f.DotGit()
62 worktree = memfs.New()
63
64 st := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())
65
66 r, err := Open(st, worktree)
67 if err != nil {
68 panic(err)
69 }
70
71 return r
72}
73
74// NewRepositoryWithEmptyWorktree returns a new repository using the .git folder
75// from the fixture but without a empty memfs worktree, the index and the

Calls 7

NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
PlainOpenFunction · 0.85
OpenFunction · 0.85
IsMethod · 0.80
RootMethod · 0.80
WorktreeMethod · 0.80

Tested by

no test coverage detected