forked from src-d/go-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git: worktree, Skip special git directory. Fixes src-d#814
Signed-off-by: kuba-- <[email protected]>
- Loading branch information
kuba--
committed
Apr 18, 2018
1 parent
b30763c
commit 6b33126
Showing
5 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
coverage.out | ||
*~ | ||
coverage.txt | ||
profile.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ package git | |
import ( | ||
"bytes" | ||
"context" | ||
"errors" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
"runtime" | ||
"testing" | ||
"time" | ||
|
||
"gopkg.in/src-d/go-git.v4/config" | ||
"gopkg.in/src-d/go-git.v4/plumbing" | ||
|
@@ -1833,3 +1835,39 @@ func (s *WorktreeSuite) TestGrep(c *C) { | |
} | ||
} | ||
} | ||
|
||
func (s *WorktreeSuite) TestAddAndCommit(c *C) { | ||
dir, err := ioutil.TempDir("", "plain-repo") | ||
c.Assert(err, IsNil) | ||
defer os.RemoveAll(dir) | ||
|
||
repo, err := PlainInit(dir, false) | ||
c.Assert(err, IsNil) | ||
|
||
w, err := repo.Worktree() | ||
c.Assert(err, IsNil) | ||
|
||
_, err = w.Add(".") | ||
c.Assert(err, IsNil) | ||
|
||
w.Commit("Test Add And Commit", &CommitOptions{Author: &object.Signature{ | ||
Name: "foo", | ||
Email: "[email protected]", | ||
When: time.Now(), | ||
}}) | ||
|
||
iter, err := w.r.Log(&LogOptions{}) | ||
c.Assert(err, IsNil) | ||
err = iter.ForEach(func(c *object.Commit) error { | ||
files, err := c.Files() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = files.ForEach(func(f *object.File) error { | ||
return errors.New("Expected no files, got at least 1") | ||
}) | ||
return err | ||
}) | ||
c.Assert(err, IsNil) | ||
} |