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

Method deleteFile

storage/github/github.go:176–207  ·  view source on GitHub ↗

deleteFile deletes a file from a Git tree and returns any applicable errors. If an empty SHA is passed as an argument, errFileNotFound is returned.

(filename string, sha string)

Source from the content-addressed store, hash-verified

174// deleteFile deletes a file from a Git tree and returns any applicable errors.
175// If an empty SHA is passed as an argument, errFileNotFound is returned.
176func (gh *Storage) deleteFile(filename string, sha string) error {
177 if err := gh.ensureClient(); err != nil {
178 return err
179 }
180
181 if sha == "" {
182 return errFileNotFound
183 }
184
185 log.Printf("github: deleting %s on branch '%s'", gh.fullPathName(filename), gh.Branch)
186
187 _, _, err := gh.client.Repositories.DeleteFile(
188 context.Background(),
189 gh.RepositoryOwner,
190 gh.RepositoryName,
191 gh.fullPathName(filename),
192 &github.RepositoryContentFileOptions{
193 Message: github.String(fmt.Sprintf("[checkup] delete %s [ci skip]", gh.fullPathName(filename))),
194 SHA: github.String(sha),
195 Branch: &gh.Branch,
196 Committer: &github.CommitAuthor{
197 Name: &gh.CommitterName,
198 Email: &gh.CommitterEmail,
199 },
200 },
201 )
202 if err != nil {
203 return err
204 }
205
206 return nil
207}
208
209// readIndex reads the index JSON from the Git repo into a map.
210// It returns the populated map & the Git SHA associated with the contents.

Callers 1

MaintainMethod · 0.95

Implementers 5

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

Calls 3

ensureClientMethod · 0.95
fullPathNameMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected