MCPcopy
hub / github.com/sourcegraph/checkup / readIndex

Method readIndex

storage/github/github.go:213–226  ·  view source on GitHub ↗

readIndex reads the index JSON from the Git repo into a map. It returns the populated map & the Git SHA associated with the contents. If the index file is not found in the Git repo, an empty index is returned with no error. If any error occurs, a nil index and empty SHA are returned along with the e

()

Source from the content-addressed store, hash-verified

211// If the index file is not found in the Git repo, an empty index is returned with no error.
212// If any error occurs, a nil index and empty SHA are returned along with the error.
213func (gh *Storage) readIndex() (map[string]int64, string, error) {
214 index := map[string]int64{}
215
216 contents, sha, err := gh.readFile(fs.IndexName)
217 if err != nil && err != errFileNotFound {
218 return nil, "", err
219 }
220 if err == errFileNotFound {
221 return index, "", nil
222 }
223
224 err = json.Unmarshal(contents, &index)
225 return index, sha, err
226}
227
228// writeIndex marshals the index into JSON and writes the file to the Git repo.
229// It returns any errors associated with marshaling the data or writing the file.

Callers 5

StoreMethod · 0.95
GetIndexMethod · 0.95
MaintainMethod · 0.95
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 1

readFileMethod · 0.95

Tested by 2

TestGitHubWithoutSubdirFunction · 0.76
TestGitHubWithSubdirFunction · 0.76