本文整理匯總了Golang中github.com/google/git-appraise/repository.Repo.ListCommitsBetween方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repo.ListCommitsBetween方法的具體用法?Golang Repo.ListCommitsBetween怎麽用?Golang Repo.ListCommitsBetween使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/git-appraise/repository.Repo
的用法示例。
在下文中一共展示了Repo.ListCommitsBetween方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getReviewCommit
// Get the commit at which the review request should be anchored.
func getReviewCommit(repo repository.Repo, r request.Request, args []string) (string, string, error) {
if len(args) > 1 {
return "", "", errors.New("Only updating a single review is supported.")
}
if len(args) == 1 {
base, err := repo.MergeBase(r.TargetRef, args[0])
if err != nil {
return "", "", err
}
return args[0], base, nil
}
base, err := repo.MergeBase(r.TargetRef, r.ReviewRef)
if err != nil {
return "", "", err
}
reviewCommits, err := repo.ListCommitsBetween(base, r.ReviewRef)
if err != nil {
return "", "", err
}
if reviewCommits == nil {
return "", "", errors.New("There are no commits included in the review request")
}
return reviewCommits[0], base, nil
}
示例2: computeReviewStartingCommit
// computeReviewStartingCommit computes the first commit in the review.
func computeReviewStartingCommit(pr github.PullRequest, repo repository.Repo) (string, error) {
if pr.Base == nil || pr.Base.SHA == nil ||
pr.Head == nil || pr.Head.SHA == nil {
return "", ErrInsufficientInfo
}
prCommits, err := repo.ListCommitsBetween(*pr.Base.SHA, *pr.Head.SHA)
if err != nil {
return "", err
}
if len(prCommits) == 0 {
return *pr.Head.SHA, nil
}
return prCommits[0], nil
}
示例3: 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
}