Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #119 from scorphus/empty-content
Browse files Browse the repository at this point in the history
Allow empty message (no content) when committing
  • Loading branch information
andrewsmedina committed Jul 23, 2014
2 parents 8b57328 + d654b40 commit 99a96c7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion repository/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func CreateTestRepository(tmp_path string, repo string, file string, content str
if err != nil {
return cleanup, err
}
cmd = exec.Command(gitPath, "commit", "-m", content)
cmd = exec.Command(gitPath, "commit", "-m", content, "--allow-empty-message")
cmd.Dir = testPath
err = cmd.Run()
return cleanup, err
Expand Down
41 changes: 38 additions & 3 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,23 @@ func (s *S) TestGetFileContentIntegration(c *gocheck.C) {
c.Assert(string(contents), gocheck.Equals, content)
}

func (s *S) TestGetFileContentIntegrationEmptyContent(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
file := "README"
content := ""
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content)
defer func() {
cleanUp()
bare = oldBare
}()
c.Assert(errCreate, gocheck.IsNil)
contents, err := GetFileContents(repo, "master", file)
c.Assert(err, gocheck.IsNil)
c.Assert(string(contents), gocheck.Equals, content)
}

func (s *S) TestGetFileContentWhenRefIsInvalid(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
Expand Down Expand Up @@ -576,7 +593,25 @@ func (s *S) TestGetTreeIntegration(c *gocheck.C) {
repo := "gandalf-test-repo"
file := "README"
content := "much WOW"
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...)
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic")
defer func() {
cleanUp()
bare = oldBare
}()
c.Assert(errCreate, gocheck.IsNil)
tree, err := GetTree(repo, "master", "much/README")
c.Assert(err, gocheck.IsNil)
c.Assert(tree[0]["path"], gocheck.Equals, "much/README")
c.Assert(tree[0]["rawPath"], gocheck.Equals, "much/README")
}

func (s *S) TestGetTreeIntegrationEmptyContent(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
file := "README"
content := ""
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic")
defer func() {
cleanUp()
bare = oldBare
Expand All @@ -594,7 +629,7 @@ func (s *S) TestGetTreeIntegrationWithEscapedFileName(c *gocheck.C) {
repo := "gandalf-test-repo"
file := "such\tREADME"
content := "much WOW"
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...)
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic")
defer func() {
cleanUp()
bare = oldBare
Expand All @@ -612,7 +647,7 @@ func (s *S) TestGetTreeIntegrationWithFileNameWithSpace(c *gocheck.C) {
repo := "gandalf-test-repo"
file := "much README"
content := "much WOW"
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...)
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic")
defer func() {
cleanUp()
bare = oldBare
Expand Down

0 comments on commit 99a96c7

Please sign in to comment.