@@ -8,33 +8,14 @@ package pipeline
8
8
import (
9
9
"bufio"
10
10
"bytes"
11
- "fmt"
12
11
"io"
13
12
"sort"
14
13
"strings"
15
14
"sync"
16
- "time"
17
15
18
16
"code.gitea.io/gitea/modules/git"
19
17
)
20
18
21
- // LFSResult represents commits found using a provided pointer file hash
22
- type LFSResult struct {
23
- Name string
24
- SHA string
25
- Summary string
26
- When time.Time
27
- ParentIDs []git.ObjectID
28
- BranchName string
29
- FullCommitName string
30
- }
31
-
32
- type lfsResultSlice []* LFSResult
33
-
34
- func (a lfsResultSlice ) Len () int { return len (a ) }
35
- func (a lfsResultSlice ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
36
- func (a lfsResultSlice ) Less (i , j int ) bool { return a [j ].When .After (a [i ].When ) }
37
-
38
19
// FindLFSFile finds commits that contain a provided pointer file hash
39
20
func FindLFSFile (repo * git.Repository , objectID git.ObjectID ) ([]* LFSResult , error ) {
40
21
resultsMap := map [string ]* LFSResult {}
@@ -137,11 +118,11 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
137
118
n += int64 (count )
138
119
if bytes .Equal (binObjectID , objectID .RawValue ()) {
139
120
result := LFSResult {
140
- Name : curPath + string (fname ),
141
- SHA : curCommit .ID .String (),
142
- Summary : strings .Split (strings .TrimSpace (curCommit .CommitMessage ), "\n " )[0 ],
143
- When : curCommit .Author .When ,
144
- ParentIDs : curCommit .Parents ,
121
+ Name : curPath + string (fname ),
122
+ SHA : curCommit .ID .String (),
123
+ Summary : strings .Split (strings .TrimSpace (curCommit .CommitMessage ), "\n " )[0 ],
124
+ When : curCommit .Author .When ,
125
+ ParentHashes : curCommit .Parents ,
145
126
}
146
127
resultsMap [curCommit .ID .String ()+ ":" + curPath + string (fname )] = & result
147
128
} else if string (mode ) == git .EntryModeTree .String () {
@@ -183,7 +164,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
183
164
184
165
for _ , result := range resultsMap {
185
166
hasParent := false
186
- for _ , parentID := range result .ParentIDs {
167
+ for _ , parentID := range result .ParentHashes {
187
168
if _ , hasParent = resultsMap [parentID .String ()+ ":" + result .Name ]; hasParent {
188
169
break
189
170
}
@@ -240,7 +221,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
240
221
select {
241
222
case err , has := <- errChan :
242
223
if has {
243
- return nil , fmt . Errorf ( "Unable to obtain name for LFS files. Error: %w " , err )
224
+ return nil , lfsError ( "unable to obtain name for LFS files" , err )
244
225
}
245
226
default :
246
227
}
0 commit comments