コード例 #1
0
ファイル: status_hook.go プロジェクト: jonbodner/lgtm
func handleSemver(c *gin.Context, user *model.User, hook *model.StatusHook, pr model.PullRequest, config *model.Config, maintainer *model.Maintainer, repo *model.Repo) (*string, error) {
	alg, err := approval.Lookup(config.ApprovalAlg)
	if err != nil {
		log.Warnf("Error getting approval algorithm %s. %s", config.ApprovalAlg, err)
		return nil, err
	}
	// to create the version, need to scan the comments on the pull request to see if anyone specified a version #
	// if so, use the largest specified version #. if not, increment the last version version # for the release
	tags, err := remote.ListTags(c, user, hook.Repo)
	if err != nil {
		log.Warnf("Unable to list tags for %s/%s: %s", hook.Repo.Owner, hook.Repo.Name, err)
	}
	maxVer := getMaxExistingTag(tags)

	comments, err := getComments(c, user, repo, pr.Number)
	if err != nil {
		log.Warnf("Unable to find the comments for pull request %s: %s", pr.Title, err)
		return nil, err
	}

	foundVersion := getMaxVersionComment(config, maintainer, pr.Issue, comments, alg)

	if foundVersion != nil && foundVersion.GreaterThan(maxVer) {
		maxVer = foundVersion
	} else {
		maxParts := maxVer.Segments()
		maxVer, _ = version.NewVersion(fmt.Sprintf("%d.%d.%d", maxParts[0], maxParts[1], maxParts[2]+1))
	}

	verStr := maxVer.String()
	return &verStr, nil
}
コード例 #2
0
ファイル: comment_hook.go プロジェクト: jonbodner/lgtm
func buildApprovers(c *gin.Context, user *model.User, repo *model.Repo, config *model.Config, maintainer *model.Maintainer, issue *model.Issue) ([]*model.Person, error) {
	comments, err := getComments(c, user, repo, issue.Number)
	if err != nil {
		log.Errorf("Error getting comments for %s/%s/%d", repo.Owner, repo.Name, issue.Number)
		c.String(500, "Error getting comments for %s/%s/%d", repo.Owner, repo.Name, issue.Number)
		return nil, err
	}

	alg, err := approval.Lookup(config.ApprovalAlg)
	if err != nil {
		log.Errorf("Error getting approval algorithm %s. %s", config.ApprovalAlg, err)
		c.String(500, "Error getting approval algorithm %s. %s", config.ApprovalAlg, err)
		return nil, err
	}
	approvers := getApprovers(config, maintainer, issue, comments, alg)
	return approvers, nil
}