func (r *release) Initialise() (action.Action, error) { // Prepare for API calls. client, owner, repo, err := r.prepareForApiCalls() if err != nil { return nil, err } // Check whether the review milestone exists or not. // People can create milestones manually, so this makes the thing more robust. title := milestoneTitle(r.v) task := fmt.Sprintf( "Check whether GitHub review milestone exists for release %v", r.v.BaseString()) log.Run(task) _, act, err := ghissues.GetOrCreateMilestoneForTitle(client, owner, repo, title) if err != nil { return nil, errs.NewError(task, err) } return act, nil }
// getOrCreateMilestone just calls ghissues.GetOrCreateMilestoneForTitle // using the client and config as contained in this issueTracker. func (tracker *issueTracker) getOrCreateMilestone( v *version.Version, ) (*github.Milestone, action.Action, error) { var ( client = tracker.newClient() owner = tracker.config.GitHubOwner repo = tracker.config.GitHubRepository title = v.BaseString() milestone *github.Milestone act action.Action err error ) withRequestAllocated(func() { milestone, act, err = ghissues.GetOrCreateMilestoneForTitle(client, owner, repo, title) }) return milestone, act, err }
func getOrCreateMilestoneForCommit( config *moduleConfig, owner string, repo string, sha string, ) (*github.Milestone, error) { // Get the version associated with the given commit. v, err := version.GetByBranch(sha) if err != nil { return nil, err } // Get or create the milestone for the given title. var ( client = ghutil.NewClient(config.Token) title = milestoneTitle(v) ) milestone, _, err := ghissues.GetOrCreateMilestoneForTitle(client, owner, repo, title) return milestone, err }