当前位置: 首页>>代码示例>>Golang>>正文


Golang Repo.GetCommitHash方法代码示例

本文整理汇总了Golang中github.com/google/git-appraise/repository.Repo.GetCommitHash方法的典型用法代码示例。如果您正苦于以下问题:Golang Repo.GetCommitHash方法的具体用法?Golang Repo.GetCommitHash怎么用?Golang Repo.GetCommitHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/google/git-appraise/repository.Repo的用法示例。


在下文中一共展示了Repo.GetCommitHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetCurrent

// GetCurrent returns the current, open code review.
//
// If there are multiple matching reviews, then an error is returned.
func GetCurrent(repo repository.Repo) (*Review, error) {
	reviewRef := repo.GetHeadRef()
	currentCommit := repo.GetCommitHash(reviewRef)
	var matchingReviews []Review
	for _, review := range ListOpen(repo) {
		if review.Request.ReviewRef == reviewRef {
			matchingReviews = append(matchingReviews, review)
		}
	}
	if matchingReviews == nil {
		return nil, nil
	}
	if len(matchingReviews) != 1 {
		return nil, fmt.Errorf("There are %d open reviews for the ref \"%s\"", len(matchingReviews), reviewRef)
	}
	r := &matchingReviews[0]
	reports := ci.ParseAllValid(repo.GetNotes(ci.Ref, currentCommit))
	r.Reports = reports
	return r, nil
}
开发者ID:davidnguyenwm,项目名称:git-appraise,代码行数:23,代码来源:review.go

示例2: requestReview

// Create a new code review request.
//
// The "args" parameter is all of the command line arguments that followed the subcommand.
func requestReview(repo repository.Repo, args []string) error {
	requestFlagSet.Parse(args)

	if !*requestAllowUncommitted {
		// Requesting a code review with uncommited local changes is usually a mistake, so
		// we want to report that to the user instead of creating the request.
		if repo.HasUncommittedChanges() {
			return errors.New("You have uncommitted or untracked files. Use --allow-uncommitted to ignore those.")
		}
	}

	r := buildRequestFromFlags(repo.GetUserEmail())
	if r.ReviewRef == "HEAD" {
		r.ReviewRef = repo.GetHeadRef()
	}
	repo.VerifyGitRefOrDie(r.TargetRef)
	repo.VerifyGitRefOrDie(r.ReviewRef)
	r.BaseCommit = repo.GetCommitHash(r.TargetRef)

	reviewCommits := repo.ListCommitsBetween(r.TargetRef, r.ReviewRef)
	if reviewCommits == nil {
		return errors.New("There are no commits included in the review request")
	}

	if r.Description == "" {
		r.Description = repo.GetCommitMessage(reviewCommits[0])
	}

	note, err := r.Write()
	if err != nil {
		return err
	}
	repo.AppendNote(request.Ref, reviewCommits[0], note)
	if !*requestQuiet {
		fmt.Printf(requestSummaryTemplate, reviewCommits[0], r.TargetRef, r.ReviewRef, r.Description)
	}
	return nil
}
开发者ID:tweezy23,项目名称:git-appraise,代码行数:41,代码来源:request.go


注:本文中的github.com/google/git-appraise/repository.Repo.GetCommitHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。