@@ -120,7 +120,7 @@ func TestEntries_Sort(t *testing.T) {
120120}
121121
122122func TestEntries_CommitsInfo (t * testing.T ) {
123- tree , err := testrepo .LsTree ("0eedd79eba4394bbef888c804e899731644367fe " )
123+ tree , err := testrepo .LsTree ("cfc3b2993f74726356887a5ec093de50486dc617 " )
124124 if err != nil {
125125 t .Fatal (err )
126126 }
@@ -130,7 +130,7 @@ func TestEntries_CommitsInfo(t *testing.T) {
130130 t .Fatal (err )
131131 }
132132
133- t .Run ("" , func (t * testing.T ) {
133+ t .Run ("general directory " , func (t * testing.T ) {
134134 es , err := tree .Entries ()
135135 if err != nil {
136136 t .Fatal (err )
@@ -226,6 +226,13 @@ func TestEntries_CommitsInfo(t *testing.T) {
226226 Commit : & Commit {
227227 ID : MustIDFromString ("0eedd79eba4394bbef888c804e899731644367fe" ),
228228 },
229+ }, {
230+ Entry : & TreeEntry {
231+ name : "sameSHAs" ,
232+ },
233+ Commit : & Commit {
234+ ID : MustIDFromString ("cfc3b2993f74726356887a5ec093de50486dc617" ),
235+ },
229236 }, {
230237 Entry : & TreeEntry {
231238 name : "src" ,
@@ -241,7 +248,7 @@ func TestEntries_CommitsInfo(t *testing.T) {
241248 }
242249 })
243250
244- t .Run ("" , func (t * testing.T ) {
251+ t .Run ("directory with submodule " , func (t * testing.T ) {
245252 subtree , err := tree .Subtree ("gogs" )
246253 if err != nil {
247254 t .Fatal (err )
@@ -274,4 +281,45 @@ func TestEntries_CommitsInfo(t *testing.T) {
274281 assert .Equal (t , expInfos [i ].Commit .ID .String (), infos [i ].Commit .ID .String (), "idx: %d" , i )
275282 }
276283 })
284+
285+ t .Run ("direcotry with files have same SHA" , func (t * testing.T ) {
286+ subtree , err := tree .Subtree ("sameSHAs" )
287+ if err != nil {
288+ t .Fatal (err )
289+ }
290+
291+ es , err := subtree .Entries ()
292+ if err != nil {
293+ t .Fatal (err )
294+ }
295+
296+ infos , err := es .CommitsInfo (c , CommitsInfoOptions {
297+ Path : "sameSHAs" ,
298+ })
299+ if err != nil {
300+ t .Fatal (err )
301+ }
302+
303+ expInfos := []* EntryCommitInfo {
304+ {
305+ Entry : & TreeEntry {
306+ name : "file1.txt" ,
307+ },
308+ Commit : & Commit {
309+ ID : MustIDFromString ("cfc3b2993f74726356887a5ec093de50486dc617" ),
310+ },
311+ }, {
312+ Entry : & TreeEntry {
313+ name : "file2.txt" ,
314+ },
315+ Commit : & Commit {
316+ ID : MustIDFromString ("cfc3b2993f74726356887a5ec093de50486dc617" ),
317+ },
318+ },
319+ }
320+ for i := range expInfos {
321+ assert .Equal (t , expInfos [i ].Entry .Name (), infos [i ].Entry .Name (), "idx: %d" , i )
322+ assert .Equal (t , expInfos [i ].Commit .ID .String (), infos [i ].Commit .ID .String (), "idx: %d" , i )
323+ }
324+ })
277325}
0 commit comments