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

Function validateProject

bridge/github/config.go:518–544  ·  view source on GitHub ↗
(owner, project string, token *auth.Token)

Source from the content-addressed store, hash-verified

516}
517
518func validateProject(owner, project string, token *auth.Token) (bool, error) {
519 url := fmt.Sprintf("%s/repos/%s/%s", githubV3Url, owner, project)
520
521 req, err := http.NewRequest("GET", url, nil)
522 if err != nil {
523 return false, err
524 }
525
526 // need the token for private repositories
527 req.Header.Set("Authorization", fmt.Sprintf("token %s", token.Value))
528
529 client := &http.Client{
530 Timeout: defaultTimeout,
531 }
532
533 resp, err := client.Do(req)
534 if err != nil {
535 return false, err
536 }
537
538 err = resp.Body.Close()
539 if err != nil {
540 return false, err
541 }
542
543 return resp.StatusCode == http.StatusOK, nil
544}
545
546func getLoginFromToken(token *auth.Token) (string, error) {
547 ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)

Callers 2

TestValidateProjectFunction · 0.70
ConfigureMethod · 0.70

Calls 2

SetMethod · 0.80
CloseMethod · 0.65

Tested by 1

TestValidateProjectFunction · 0.56