MCPcopy Index your code
hub / github.com/git-bug/git-bug / deleteRepository

Function deleteRepository

bridge/github/export_test.go:344–372  ·  view source on GitHub ↗

delete repository need a token with scope 'delete_repo'

(project, owner, token string)

Source from the content-addressed store, hash-verified

342
343// delete repository need a token with scope 'delete_repo'
344func deleteRepository(project, owner, token string) error {
345 // This function use the V3 Github API because repository removal is not supported yet on the V4 API.
346 url := fmt.Sprintf("%s/repos/%s/%s", githubV3Url, owner, project)
347
348 req, err := http.NewRequest("DELETE", url, nil)
349 if err != nil {
350 return err
351 }
352
353 // need the token for private repositories
354 req.Header.Set("Authorization", fmt.Sprintf("token %s", token))
355
356 client := &http.Client{
357 Timeout: defaultTimeout,
358 }
359
360 resp, err := client.Do(req)
361 if err != nil {
362 return err
363 }
364
365 defer resp.Body.Close()
366
367 if resp.StatusCode != http.StatusNoContent {
368 return fmt.Errorf("error deleting repository")
369 }
370
371 return nil
372}

Callers 1

TestGithubPushPullFunction · 0.70

Calls 3

SetMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected