Skip to content

Commit

Permalink
git: worktree, Fix tests affected by changed Commit method.
Browse files Browse the repository at this point in the history
  • Loading branch information
onee-only committed Mar 13, 2024
1 parent 1906753 commit d2f2f86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion worktree_commit_test.go
Expand Up @@ -365,7 +365,8 @@ func (s *WorktreeSuite) TestAddAndCommitWithSkipStatusPathNotModified(c *C) {
c.Assert(foo.Worktree, Equals, Untracked)

hash, err = w.Commit("commit with no changes\n", &CommitOptions{
Author: defaultSignature(),
Author: defaultSignature(),
AllowEmptyCommits: true,
})
c.Assert(hash, Equals, expected2)
c.Assert(err, IsNil)
Expand Down
15 changes: 10 additions & 5 deletions worktree_test.go
Expand Up @@ -88,8 +88,9 @@ func (s *WorktreeSuite) TestPullFastForward(c *C) {

w, err := server.Worktree()
c.Assert(err, IsNil)
err = os.WriteFile(filepath.Join(path, "foo"), []byte("foo"), 0755)
err = os.WriteFile(filepath.Join(url, "foo"), []byte("foo"), 0755)
c.Assert(err, IsNil)
w.Add("foo")
hash, err := w.Commit("foo", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)

Expand Down Expand Up @@ -125,15 +126,17 @@ func (s *WorktreeSuite) TestPullNonFastForward(c *C) {

w, err := server.Worktree()
c.Assert(err, IsNil)
err = os.WriteFile(filepath.Join(path, "foo"), []byte("foo"), 0755)
err = os.WriteFile(filepath.Join(url, "foo"), []byte("foo"), 0755)
c.Assert(err, IsNil)
w.Add("foo")
_, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)

w, err = r.Worktree()
c.Assert(err, IsNil)
err = os.WriteFile(filepath.Join(path, "bar"), []byte("bar"), 0755)
err = os.WriteFile(filepath.Join(dir, "bar"), []byte("bar"), 0755)
c.Assert(err, IsNil)
w.Add("bar")
_, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)

Expand Down Expand Up @@ -286,16 +289,18 @@ func (s *RepositorySuite) TestPullAdd(c *C) {
func (s *WorktreeSuite) TestPullAlreadyUptodate(c *C) {
path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()

r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
fs := memfs.New()
r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
URL: filepath.Join(path, ".git"),
})

c.Assert(err, IsNil)

w, err := r.Worktree()
c.Assert(err, IsNil)
err = os.WriteFile(filepath.Join(path, "bar"), []byte("bar"), 0755)
util.WriteFile(fs, "bar", []byte("bar"), 0755)
c.Assert(err, IsNil)
w.Add("bar")
_, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)

Expand Down

0 comments on commit d2f2f86

Please sign in to comment.