| 136 | } |
| 137 | |
| 138 | func (s *SuiteCommit) TestPatchContext(c *C) { |
| 139 | from := s.commit(c, plumbing.NewHash("918c48b83bd081e863dbe1b80f8998f058cd8294")) |
| 140 | to := s.commit(c, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) |
| 141 | |
| 142 | patch, err := from.PatchContext(context.Background(), to) |
| 143 | c.Assert(err, IsNil) |
| 144 | |
| 145 | buf := bytes.NewBuffer(nil) |
| 146 | err = patch.Encode(buf) |
| 147 | c.Assert(err, IsNil) |
| 148 | |
| 149 | c.Assert(buf.String(), Equals, `diff --git a/vendor/foo.go b/vendor/foo.go |
| 150 | new file mode 100644 |
| 151 | index 0000000000000000000000000000000000000000..9dea2395f5403188298c1dabe8bdafe562c491e3 |
| 152 | --- /dev/null |
| 153 | +++ b/vendor/foo.go |
| 154 | @@ -0,0 +1,7 @@ |
| 155 | +package main |
| 156 | + |
| 157 | +import "fmt" |
| 158 | + |
| 159 | +func main() { |
| 160 | + fmt.Println("Hello, playground") |
| 161 | +} |
| 162 | `) |
| 163 | c.Assert(buf.String(), Equals, patch.String()) |
| 164 | |
| 165 | from = s.commit(c, plumbing.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47")) |
| 166 | to = s.commit(c, plumbing.NewHash("35e85108805c84807bc66a02d91535e1e24b38b9")) |
| 167 | |
| 168 | patch, err = from.PatchContext(context.Background(), to) |
| 169 | c.Assert(err, IsNil) |
| 170 | |
| 171 | buf.Reset() |
| 172 | err = patch.Encode(buf) |
| 173 | c.Assert(err, IsNil) |
| 174 | |
| 175 | c.Assert(buf.String(), Equals, `diff --git a/CHANGELOG b/CHANGELOG |
| 176 | deleted file mode 100644 |
| 177 | index d3ff53e0564a9f87d8e84b6e28e5060e517008aa..0000000000000000000000000000000000000000 |
| 178 | --- a/CHANGELOG |
| 179 | +++ /dev/null |
| 180 | @@ -1 +0,0 @@ |
| 181 | -Initial changelog |
| 182 | diff --git a/binary.jpg b/binary.jpg |
| 183 | new file mode 100644 |
| 184 | index 0000000000000000000000000000000000000000..d5c0f4ab811897cadf03aec358ae60d21f91c50d |
| 185 | Binary files /dev/null and b/binary.jpg differ |
| 186 | `) |
| 187 | |
| 188 | c.Assert(buf.String(), Equals, patch.String()) |
| 189 | } |
| 190 | |
| 191 | func (s *SuiteCommit) TestPatchContext_ToNil(c *C) { |
| 192 | from := s.commit(c, plumbing.NewHash("918c48b83bd081e863dbe1b80f8998f058cd8294")) |