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)
| 48 | // is tagged as worktree the filesystem from fixture is used, otherwise a new |
| 49 | // memfs filesystem is used as worktree. |
| 50 | func (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 |
no test coverage detected