MCPcopy Index your code
hub / github.com/sourcegraph/checkup / Store

Method Store

storage/github/github.go:240–260  ·  view source on GitHub ↗

Store stores results in the Git repo & updates the index.

(results []types.Result)

Source from the content-addressed store, hash-verified

238
239// Store stores results in the Git repo & updates the index.
240func (gh *Storage) Store(results []types.Result) error {
241 // Write results to a new file
242 name := *fs.GenerateFilename()
243 contents, err := json.Marshal(results)
244 if err != nil {
245 return err
246 }
247 err = gh.writeFile(name, "", contents)
248
249 // Read current index file
250 index, indexSHA, err := gh.readIndex()
251 if err != nil {
252 return err
253 }
254
255 // Add new file to index
256 index[name] = time.Now().UnixNano()
257
258 // Write new index
259 return gh.writeIndex(index, indexSHA)
260}
261
262// Fetch returns a checkup record -- Not tested!
263func (gh *Storage) Fetch(name string) ([]types.Result, error) {

Callers 2

TestGitHubWithoutSubdirFunction · 0.95
TestGitHubWithSubdirFunction · 0.95

Implementers 5

fakecheckup_test.go
Storagestorage/sql/sql.go
Storagestorage/s3/s3.go
Storagestorage/github/github.go
Storagestorage/fs/fs.go

Calls 4

writeFileMethod · 0.95
readIndexMethod · 0.95
writeIndexMethod · 0.95
GenerateFilenameFunction · 0.92

Tested by 2

TestGitHubWithoutSubdirFunction · 0.76
TestGitHubWithSubdirFunction · 0.76