This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree 4 files changed +36
-2
lines changed
4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
130
130
131
131
var message bool
132
132
for {
133
- line , err := r .ReadSlice ('\n' )
133
+ line , err := r .ReadBytes ('\n' )
134
134
if err != nil && err != io .EOF {
135
135
return err
136
136
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package object
2
2
3
3
import (
4
4
"io"
5
+ "strings"
5
6
"time"
6
7
7
8
"github.com/src-d/go-git-fixtures"
@@ -167,3 +168,19 @@ func (s *SuiteCommit) TestCommitIterNext(c *C) {
167
168
c .Assert (err , Equals , io .EOF )
168
169
c .Assert (commit , IsNil )
169
170
}
171
+
172
+ func (s * SuiteCommit ) TestLongCommitMessageSerialization (c * C ) {
173
+ encoded := & plumbing.MemoryObject {}
174
+ decoded := & Commit {}
175
+ commit := * s .Commit
176
+
177
+ longMessage := "my message: message\n \n " + strings .Repeat ("test" , 4096 ) + "\n OK"
178
+ commit .Message = longMessage
179
+
180
+ err := commit .Encode (encoded )
181
+ c .Assert (err , IsNil )
182
+
183
+ err = decoded .Decode (encoded )
184
+ c .Assert (err , IsNil )
185
+ c .Assert (decoded .Message , Equals , longMessage )
186
+ }
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ func (t *Tag) Decode(o plumbing.EncodedObject) (err error) {
90
90
91
91
r := bufio .NewReader (reader )
92
92
for {
93
- line , err := r .ReadSlice ('\n' )
93
+ line , err := r .ReadBytes ('\n' )
94
94
if err != nil && err != io .EOF {
95
95
return err
96
96
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package object
3
3
import (
4
4
"fmt"
5
5
"io"
6
+ "strings"
6
7
"time"
7
8
8
9
"github.com/src-d/go-git-fixtures"
@@ -269,3 +270,19 @@ func (s *TagSuite) TestTagToTagString(c *C) {
269
270
"\n " +
270
271
"\n " )
271
272
}
273
+
274
+ func (s * TagSuite ) TestLongTagNameSerialization (c * C ) {
275
+ encoded := & plumbing.MemoryObject {}
276
+ decoded := & Tag {}
277
+ tag := s .tag (c , plumbing .NewHash ("b742a2a9fa0afcfa9a6fad080980fbc26b007c69" ))
278
+
279
+ longName := "my tag: name " + strings .Repeat ("test" , 4096 ) + " OK"
280
+ tag .Name = longName
281
+
282
+ err := tag .Encode (encoded )
283
+ c .Assert (err , IsNil )
284
+
285
+ err = decoded .Decode (encoded )
286
+ c .Assert (err , IsNil )
287
+ c .Assert (decoded .Name , Equals , longName )
288
+ }
You can’t perform that action at this time.
0 commit comments