本文整理匯總了Golang中github.com/google/git-appraise/review.Review.GetBaseCommit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Review.GetBaseCommit方法的具體用法?Golang Review.GetBaseCommit怎麽用?Golang Review.GetBaseCommit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/git-appraise/review.Review
的用法示例。
在下文中一共展示了Review.GetBaseCommit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: EnsureRequestExists
// EnsureRequestExists runs the "arcanist" command-line tool to create a Differential diff for the given request, if one does not already exist.
func (arc Arcanist) EnsureRequestExists(repo repository.Repo, review review.Review) {
revision := review.Revision
req := review.Request
// If this revision has been previously closed shortcut all processing
if closedRevisionsMap[revision] {
return
}
existingReviews := arc.listDifferentialReviewsOrDie(revision)
if review.Submitted {
// The change has already been merged in, so we should simply close any open reviews.
for _, differentialReview := range existingReviews {
if !differentialReview.isClosed() {
differentialReview.close()
}
}
closedRevisionsMap[revision] = true
return
}
base, err := review.GetBaseCommit()
if err != nil {
// There are lots of reasons that we might not be able to compute a base commit,
// (e.g. the revision already being merged in, or being dropped and garbage collected),
// but they all indicate that the review request is no longer valid.
log.Printf("Ignoring review request '%v', because we could not compute a base commit", req)
return
}
head, err := review.GetHeadCommit()
if err != nil {
// The given review ref has been deleted (or never existed), but the change wasn't merged.
// TODO(ojarjur): We should mark the existing reviews as abandoned.
log.Printf("Ignoring review because the review ref '%s' does not exist", req.ReviewRef)
return
}
if len(existingReviews) > 0 {
// The change is still pending, but we already have existing reviews, so we should just update those.
for _, existing := range existingReviews {
arc.updateReviewDiffs(repo, existing, head, req, review)
}
return
}
diff, err := arc.createDifferentialDiff(repo, base, revision, req, []string{})
if err != nil {
log.Fatal(err)
}
if diff == nil {
// The revision is already merged in, ignore it.
return
}
rev, err := arc.createDifferentialRevision(repo, revision, diff.ID, req)
if err != nil {
log.Fatal(err)
}
log.Printf("Created diff %v and revision %v for the review of %s", diff, rev, revision)
// If the review already contains multiple commits by the time we mirror it, then
// we need to ensure that at least the first and last ones are added.
existingReviews = arc.listDifferentialReviewsOrDie(revision)
for _, existing := range existingReviews {
arc.updateReviewDiffs(repo, existing, head, req, review)
}
}