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

Commit

Permalink
Allow empty message (no content) when committing
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Jul 23, 2014
1 parent 00612ed commit d654b40
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
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
35 changes: 35 additions & 0 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 @@ -588,6 +605,24 @@ func (s *S) TestGetTreeIntegration(c *gocheck.C) {
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
}()
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) TestGetTreeIntegrationWithEscapedFileName(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
Expand Down

0 comments on commit d654b40

Please sign in to comment.