diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-09-06 22:05:00 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2018-09-06 22:05:00 +0200 |
commit | d3cec13ac0b195bfb897ed038a08b5130ab9969e (patch) | |
tree | b54b622402057e530cc4b05fb2ffa36767ba726e /worktree_commit_test.go | |
parent | 174f373cf066afc3e3be35576adf3709b0ee278b (diff) | |
parent | f0c4318e7b8d5cbf91723c71a4ba20d1bd0cfaf5 (diff) | |
download | go-git-d3cec13ac0b195bfb897ed038a08b5130ab9969e.tar.gz |
worktree: solve merge conflictsv4.7.0
Diffstat (limited to 'worktree_commit_test.go')
-rw-r--r-- | worktree_commit_test.go | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/worktree_commit_test.go b/worktree_commit_test.go index 004926f..6979bd5 100644 --- a/worktree_commit_test.go +++ b/worktree_commit_test.go @@ -2,19 +2,24 @@ package git import ( "bytes" + "io/ioutil" + "os" + "os/exec" "strings" "time" - "golang.org/x/crypto/openpgp" - "golang.org/x/crypto/openpgp/armor" - "golang.org/x/crypto/openpgp/errors" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/storer" + "gopkg.in/src-d/go-git.v4/storage/filesystem" "gopkg.in/src-d/go-git.v4/storage/memory" + "golang.org/x/crypto/openpgp" + "golang.org/x/crypto/openpgp/armor" + "golang.org/x/crypto/openpgp/errors" . "gopkg.in/check.v1" "gopkg.in/src-d/go-billy.v4/memfs" + "gopkg.in/src-d/go-billy.v4/osfs" "gopkg.in/src-d/go-billy.v4/util" ) @@ -196,6 +201,54 @@ func (s *WorktreeSuite) TestCommitSignBadKey(c *C) { c.Assert(err, Equals, errors.InvalidArgumentError("signing key is encrypted")) } +func (s *WorktreeSuite) TestCommitTreeSort(c *C) { + path, err := ioutil.TempDir(os.TempDir(), "test-commit-tree-sort") + c.Assert(err, IsNil) + fs := osfs.New(path) + st, err := filesystem.NewStorage(fs) + c.Assert(err, IsNil) + r, err := Init(st, nil) + c.Assert(err, IsNil) + + r, err = Clone(memory.NewStorage(), memfs.New(), &CloneOptions{ + URL: path, + }) + + w, err := r.Worktree() + c.Assert(err, IsNil) + + mfs := w.Filesystem + + err = mfs.MkdirAll("delta", 0755) + c.Assert(err, IsNil) + + for _, p := range []string{"delta_last", "Gamma", "delta/middle", "Beta", "delta-first", "alpha"} { + util.WriteFile(mfs, p, []byte("foo"), 0644) + _, err = w.Add(p) + c.Assert(err, IsNil) + } + + _, err = w.Commit("foo\n", &CommitOptions{ + All: true, + Author: defaultSignature(), + }) + c.Assert(err, IsNil) + + err = r.Push(&PushOptions{}) + c.Assert(err, IsNil) + + cmd := exec.Command("git", "fsck") + cmd.Dir = path + cmd.Env = os.Environ() + buf := &bytes.Buffer{} + cmd.Stderr = buf + cmd.Stdout = buf + + err = cmd.Run() + + c.Assert(err, IsNil, Commentf("%s", buf.Bytes())) +} + func assertStorageStatus( c *C, r *Repository, treesCount, blobCount, commitCount int, head plumbing.Hash, |