aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-09-01 17:28:42 +0200
committerGitHub <noreply@github.com>2017-09-01 17:28:42 +0200
commitc20028f6a4d0038d59898392aafe13baa9e84040 (patch)
tree49407f8b3b5aaef1c6a56363bdb1fc25cd56f5cb /repository_test.go
parent8ce9f5f240730ce21f50e42409d17fac7d71e051 (diff)
parent76efca13092ba245caf15f232f467e68fa1f73ed (diff)
downloadgo-git-c20028f6a4d0038d59898392aafe13baa9e84040.tar.gz
Merge pull request #573 from orirawlings/pushSideband
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{