@@ -34,12 +34,12 @@ import (
34
34
)
35
35
36
36
var (
37
- _ clients.RepoClient = & localDirClient {}
37
+ _ clients.RepoClient = & Client {}
38
38
errInputRepoType = errors .New ("input repo should be of type repoLocal" )
39
39
)
40
40
41
41
//nolint:govet
42
- type localDirClient struct {
42
+ type Client struct {
43
43
logger * log.Logger
44
44
ctx context.Context
45
45
path string
@@ -50,7 +50,7 @@ type localDirClient struct {
50
50
}
51
51
52
52
// InitRepo sets up the local repo.
53
- func (client * localDirClient ) InitRepo (inputRepo clients.Repo , commitSHA string , commitDepth int ) error {
53
+ func (client * Client ) InitRepo (inputRepo clients.Repo , commitSHA string , commitDepth int ) error {
54
54
localRepo , ok := inputRepo .(* Repo )
55
55
if ! ok {
56
56
return fmt .Errorf ("%w: %v" , errInputRepoType , inputRepo )
@@ -66,12 +66,12 @@ func (client *localDirClient) InitRepo(inputRepo clients.Repo, commitSHA string,
66
66
}
67
67
68
68
// URI implements RepoClient.URI.
69
- func (client * localDirClient ) URI () string {
69
+ func (client * Client ) URI () string {
70
70
return fmt .Sprintf ("file://%s" , client .path )
71
71
}
72
72
73
73
// IsArchived implements RepoClient.IsArchived.
74
- func (client * localDirClient ) IsArchived () (bool , error ) {
74
+ func (client * Client ) IsArchived () (bool , error ) {
75
75
return false , fmt .Errorf ("IsArchived: %w" , clients .ErrUnsupportedFeature )
76
76
}
77
77
@@ -148,7 +148,7 @@ func applyPredicate(
148
148
}
149
149
150
150
// LocalPath implements RepoClient.LocalPath.
151
- func (client * localDirClient ) LocalPath () (string , error ) {
151
+ func (client * Client ) LocalPath () (string , error ) {
152
152
clientPath , err := filepath .Abs (client .path )
153
153
if err != nil {
154
154
return "" , fmt .Errorf ("error during filepath.Abs: %w" , err )
@@ -157,7 +157,7 @@ func (client *localDirClient) LocalPath() (string, error) {
157
157
}
158
158
159
159
// ListFiles implements RepoClient.ListFiles.
160
- func (client * localDirClient ) ListFiles (predicate func (string ) (bool , error )) ([]string , error ) {
160
+ func (client * Client ) ListFiles (predicate func (string ) (bool , error )) ([]string , error ) {
161
161
client .once .Do (func () {
162
162
client .files , client .errFiles = listFiles (client .path )
163
163
})
@@ -175,102 +175,103 @@ func getFile(clientpath, filename string) (*os.File, error) {
175
175
}
176
176
177
177
// GetFileReader implements RepoClient.GetFileReader.
178
- func (client * localDirClient ) GetFileReader (filename string ) (io.ReadCloser , error ) {
178
+ func (client * Client ) GetFileReader (filename string ) (io.ReadCloser , error ) {
179
179
return getFile (client .path , filename )
180
180
}
181
181
182
182
// GetBranch implements RepoClient.GetBranch.
183
- func (client * localDirClient ) GetBranch (branch string ) (* clients.BranchRef , error ) {
183
+ func (client * Client ) GetBranch (branch string ) (* clients.BranchRef , error ) {
184
184
return nil , fmt .Errorf ("ListBranches: %w" , clients .ErrUnsupportedFeature )
185
185
}
186
186
187
187
// GetDefaultBranch implements RepoClient.GetDefaultBranch.
188
- func (client * localDirClient ) GetDefaultBranch () (* clients.BranchRef , error ) {
188
+ func (client * Client ) GetDefaultBranch () (* clients.BranchRef , error ) {
189
189
return nil , fmt .Errorf ("GetDefaultBranch: %w" , clients .ErrUnsupportedFeature )
190
190
}
191
191
192
192
// GetDefaultBranchName implements RepoClient.GetDefaultBranchName.
193
- func (client * localDirClient ) GetDefaultBranchName () (string , error ) {
193
+ func (client * Client ) GetDefaultBranchName () (string , error ) {
194
194
return "" , fmt .Errorf ("GetDefaultBranchName: %w" , clients .ErrUnsupportedFeature )
195
195
}
196
196
197
197
// ListCommits implements RepoClient.ListCommits.
198
- func (client * localDirClient ) ListCommits () ([]clients.Commit , error ) {
198
+ func (client * Client ) ListCommits () ([]clients.Commit , error ) {
199
199
return nil , fmt .Errorf ("ListCommits: %w" , clients .ErrUnsupportedFeature )
200
200
}
201
201
202
202
// ListIssues implements RepoClient.ListIssues.
203
- func (client * localDirClient ) ListIssues () ([]clients.Issue , error ) {
203
+ func (client * Client ) ListIssues () ([]clients.Issue , error ) {
204
204
return nil , fmt .Errorf ("ListIssues: %w" , clients .ErrUnsupportedFeature )
205
205
}
206
206
207
207
// ListReleases implements RepoClient.ListReleases.
208
- func (client * localDirClient ) ListReleases () ([]clients.Release , error ) {
208
+ func (client * Client ) ListReleases () ([]clients.Release , error ) {
209
209
return nil , fmt .Errorf ("ListReleases: %w" , clients .ErrUnsupportedFeature )
210
210
}
211
211
212
212
// ListContributors implements RepoClient.ListContributors.
213
- func (client * localDirClient ) ListContributors () ([]clients.User , error ) {
213
+ func (client * Client ) ListContributors () ([]clients.User , error ) {
214
214
return nil , fmt .Errorf ("ListContributors: %w" , clients .ErrUnsupportedFeature )
215
215
}
216
216
217
217
// ListSuccessfulWorkflowRuns implements RepoClient.WorkflowRunsByFilename.
218
- func (client * localDirClient ) ListSuccessfulWorkflowRuns (filename string ) ([]clients.WorkflowRun , error ) {
218
+ func (client * Client ) ListSuccessfulWorkflowRuns (filename string ) ([]clients.WorkflowRun , error ) {
219
219
return nil , fmt .Errorf ("ListSuccessfulWorkflowRuns: %w" , clients .ErrUnsupportedFeature )
220
220
}
221
221
222
222
// ListCheckRunsForRef implements RepoClient.ListCheckRunsForRef.
223
- func (client * localDirClient ) ListCheckRunsForRef (ref string ) ([]clients.CheckRun , error ) {
223
+ func (client * Client ) ListCheckRunsForRef (ref string ) ([]clients.CheckRun , error ) {
224
224
return nil , fmt .Errorf ("ListCheckRunsForRef: %w" , clients .ErrUnsupportedFeature )
225
225
}
226
226
227
227
// ListStatuses implements RepoClient.ListStatuses.
228
- func (client * localDirClient ) ListStatuses (ref string ) ([]clients.Status , error ) {
228
+ func (client * Client ) ListStatuses (ref string ) ([]clients.Status , error ) {
229
229
return nil , fmt .Errorf ("ListStatuses: %w" , clients .ErrUnsupportedFeature )
230
230
}
231
231
232
232
// ListWebhooks implements RepoClient.ListWebhooks.
233
- func (client * localDirClient ) ListWebhooks () ([]clients.Webhook , error ) {
233
+ func (client * Client ) ListWebhooks () ([]clients.Webhook , error ) {
234
234
return nil , fmt .Errorf ("ListWebhooks: %w" , clients .ErrUnsupportedFeature )
235
235
}
236
236
237
237
// Search implements RepoClient.Search.
238
- func (client * localDirClient ) Search (request clients.SearchRequest ) (clients.SearchResponse , error ) {
238
+ func (client * Client ) Search (request clients.SearchRequest ) (clients.SearchResponse , error ) {
239
239
return clients.SearchResponse {}, fmt .Errorf ("Search: %w" , clients .ErrUnsupportedFeature )
240
240
}
241
241
242
242
// SearchCommits implements RepoClient.SearchCommits.
243
- func (client * localDirClient ) SearchCommits (request clients.SearchCommitsOptions ) ([]clients.Commit , error ) {
243
+ func (client * Client ) SearchCommits (request clients.SearchCommitsOptions ) ([]clients.Commit , error ) {
244
244
return nil , fmt .Errorf ("Search: %w" , clients .ErrUnsupportedFeature )
245
245
}
246
246
247
- func (client * localDirClient ) Close () error {
247
+ func (client * Client ) Close () error {
248
248
return nil
249
249
}
250
250
251
251
// ListProgrammingLanguages implements RepoClient.ListProgrammingLanguages.
252
252
// TODO: add ListProgrammingLanguages support for local directories.
253
- func (client * localDirClient ) ListProgrammingLanguages () ([]clients.Language , error ) {
254
- return nil , fmt .Errorf ("ListProgrammingLanguages: %w" , clients .ErrUnsupportedFeature )
253
+ func (client * Client ) ListProgrammingLanguages () ([]clients.Language , error ) {
254
+ // for now just return all programming languages
255
+ return []clients.Language {{Name : clients .All , NumLines : 1 }}, nil
255
256
}
256
257
257
258
// ListLicenses implements RepoClient.ListLicenses.
258
259
// TODO: add ListLicenses support for local directories.
259
- func (client * localDirClient ) ListLicenses () ([]clients.License , error ) {
260
+ func (client * Client ) ListLicenses () ([]clients.License , error ) {
260
261
return nil , fmt .Errorf ("ListLicenses: %w" , clients .ErrUnsupportedFeature )
261
262
}
262
263
263
- func (client * localDirClient ) GetCreatedAt () (time.Time , error ) {
264
+ func (client * Client ) GetCreatedAt () (time.Time , error ) {
264
265
return time.Time {}, fmt .Errorf ("GetCreatedAt: %w" , clients .ErrUnsupportedFeature )
265
266
}
266
267
267
- func (client * localDirClient ) GetOrgRepoClient (ctx context.Context ) (clients.RepoClient , error ) {
268
+ func (client * Client ) GetOrgRepoClient (ctx context.Context ) (clients.RepoClient , error ) {
268
269
return nil , fmt .Errorf ("GetOrgRepoClient: %w" , clients .ErrUnsupportedFeature )
269
270
}
270
271
271
272
// CreateLocalDirClient returns a client which implements RepoClient interface.
272
273
func CreateLocalDirClient (ctx context.Context , logger * log.Logger ) clients.RepoClient {
273
- return & localDirClient {
274
+ return & Client {
274
275
ctx : ctx ,
275
276
logger : logger ,
276
277
}
0 commit comments