aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorOri Rawlings <orirawlings@gmail.com>2017-08-23 21:37:49 -0500
committerOri Rawlings <orirawlings@gmail.com>2017-09-01 09:17:23 -0500
commit76efca13092ba245caf15f232f467e68fa1f73ed (patch)
treee94ed3536e5af8d9201e83de9a7011ab5ac37dad /repository_test.go
parent3ca370277427c5d508f0dedacbd559523a305121 (diff)
downloadgo-git-76efca13092ba245caf15f232f467e68fa1f73ed.tar.gz
Add sideband support for push
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index e944251..6184949 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -719,6 +719,47 @@ func (s *RepositorySuite) TestPushContext(c *C) {
c.Assert(err, NotNil)
}
+// installPreReceiveHook installs a pre-receive hook in the .git
+// directory at path which prints message m before exiting
+// successfully.
+func installPreReceiveHook(c *C, path, m string) {
+ hooks := filepath.Join(path, "hooks")
+ err := os.MkdirAll(hooks, 0777)
+ c.Assert(err, IsNil)
+
+ err = ioutil.WriteFile(filepath.Join(hooks, "pre-receive"), preReceiveHook(m), 0777)
+ c.Assert(err, IsNil)
+}
+
+func (s *RepositorySuite) TestPushWithProgress(c *C) {
+ url := c.MkDir()
+ server, err := PlainInit(url, true)
+ c.Assert(err, IsNil)
+
+ m := "Receiving..."
+ installPreReceiveHook(c, url, m)
+
+ _, err = s.Repository.CreateRemote(&config.RemoteConfig{
+ Name: "bar",
+ URLs: []string{url},
+ })
+ c.Assert(err, IsNil)
+
+ var p bytes.Buffer
+ err = s.Repository.Push(&PushOptions{
+ RemoteName: "bar",
+ Progress: &p,
+ })
+ c.Assert(err, IsNil)
+
+ AssertReferences(c, server, map[string]string{
+ "refs/heads/master": "6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
+ "refs/heads/branch": "e8d3ffab552895c19b9fcf7aa264d277cde33881",
+ })
+
+ c.Assert((&p).Bytes(), DeepEquals, []byte(m))
+}
+
func (s *RepositorySuite) TestPushDepth(c *C) {
url := c.MkDir()
server, err := PlainClone(url, true, &CloneOptions{