Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
// 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
}
Ejemplo n.º 3
0
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
}