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

Method getOrCreateGithubLabelID

bridge/github/export.go:598–618  ·  view source on GitHub ↗

** // create github label using api v4 func (ge *githubExporter) createGithubLabelV4(gc *githubv4.Client, label, labelColor string) (string, error) { m := createLabelMutation{} input := createLabelInput{ RepositoryID: ge.repositoryID, Name: githubv4.String(label), Color: githu

(ctx context.Context, gc *rateLimitHandlerClient, repositoryID string, label common.Label)

Source from the content-addressed store, hash-verified

596*/
597
598func (ge *githubExporter) getOrCreateGithubLabelID(ctx context.Context, gc *rateLimitHandlerClient, repositoryID string, label common.Label) (string, error) {
599 // try to get label id from cache
600 labelID, err := ge.getLabelID(string(label))
601 if err == nil {
602 return labelID, nil
603 }
604
605 // RGBA to hex color
606 rgba := label.Color().RGBA()
607 hexColor := fmt.Sprintf("%.2x%.2x%.2x", rgba.R, rgba.G, rgba.B)
608
609 ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
610 defer cancel()
611
612 labelID, err = ge.createGithubLabel(ctx, string(label), hexColor)
613 if err != nil {
614 return "", err
615 }
616
617 return labelID, nil
618}
619
620func (ge *githubExporter) getLabelsIDs(ctx context.Context, gc *rateLimitHandlerClient, repositoryID string, labels []common.Label) ([]githubv4.ID, error) {
621 ids := make([]githubv4.ID, 0, len(labels))

Callers 1

getLabelsIDsMethod · 0.95

Calls 4

getLabelIDMethod · 0.95
createGithubLabelMethod · 0.95
RGBAMethod · 0.80
ColorMethod · 0.65

Tested by

no test coverage detected