本文整理匯總了Golang中github.com/google/git-appraise/repository.Repo.IsAncestor方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repo.IsAncestor方法的具體用法?Golang Repo.IsAncestor怎麽用?Golang Repo.IsAncestor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/git-appraise/repository.Repo
的用法示例。
在下文中一共展示了Repo.IsAncestor方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetSummary
// GetSummary returns the summary of the specified code review.
//
// If no review request exists, the returned review summary is nil.
func GetSummary(repo repository.Repo, revision string) (*Summary, error) {
requestNotes := repo.GetNotes(request.Ref, revision)
commentNotes := repo.GetNotes(comment.Ref, revision)
summary, err := getSummaryFromNotes(repo, revision, requestNotes, commentNotes)
if err != nil {
return nil, err
}
currentCommit := revision
if summary.Request.Alias != "" {
currentCommit = summary.Request.Alias
}
submitted, err := repo.IsAncestor(currentCommit, summary.Request.TargetRef)
if err != nil {
return nil, err
}
summary.Submitted = submitted
return summary, nil
}
示例2: Get
// Get returns the specified code review.
//
// If no review request exists, the returned review is nil.
func Get(repo repository.Repo, revision string) *Review {
requestNotes := repo.GetNotes(request.Ref, revision)
requests := request.ParseAllValid(requestNotes)
if requests == nil {
return nil
}
review := Review{
Repo: repo,
Revision: revision,
Request: requests[len(requests)-1],
}
review.Comments = review.loadComments()
review.Resolved = updateThreadsStatus(review.Comments)
review.Submitted = repo.IsAncestor(revision, review.Request.TargetRef)
// TODO(ojarjur): Optionally fetch the CI status of the last commit
// in the review for which there are comments.
return &review
}
示例3: GetSummary
// Get returns the summary of the specified code review.
//
// If no review request exists, the returned review summary is nil.
func GetSummary(repo repository.Repo, revision string) (*ReviewSummary, error) {
requestNotes := repo.GetNotes(request.Ref, revision)
requests := request.ParseAllValid(requestNotes)
if requests == nil {
return nil, nil
}
reviewSummary := ReviewSummary{
Repo: repo,
Revision: revision,
Request: requests[len(requests)-1],
}
reviewSummary.Comments = reviewSummary.loadComments()
reviewSummary.Resolved = updateThreadsStatus(reviewSummary.Comments)
submitted, err := repo.IsAncestor(revision, reviewSummary.Request.TargetRef)
if err != nil {
return nil, err
}
reviewSummary.Submitted = submitted
return &reviewSummary, nil
}
示例4: Get
// Get returns the specified code review.
//
// If no review request exists, the returned review is nil.
func Get(repo repository.Repo, revision string) *Review {
requestNotes := repo.GetNotes(request.Ref, revision)
requests := request.ParseAllValid(requestNotes)
if requests == nil {
return nil
}
review := Review{
Repo: repo,
Revision: revision,
Request: requests[len(requests)-1],
}
review.Comments = review.loadComments()
review.Resolved = updateThreadsStatus(review.Comments)
review.Submitted = repo.IsAncestor(revision, review.Request.TargetRef)
currentCommit, err := review.GetHeadCommit()
if err == nil {
review.Reports = ci.ParseAllValid(repo.GetNotes(ci.Ref, currentCommit))
review.Analyses = analyses.ParseAllValid(repo.GetNotes(analyses.Ref, currentCommit))
}
return &review
}
示例5: submitReview
// Submit the current code review request.
//
// The "args" parameter contains all of the command line arguments that followed the subcommand.
func submitReview(repo repository.Repo, args []string) error {
submitFlagSet.Parse(args)
if *submitMerge && *submitRebase {
return errors.New("Only one of --merge or --rebase is allowed.")
}
r, err := review.GetCurrent(repo)
if err != nil {
return err
}
if r == nil {
return errors.New("There is nothing to submit")
}
if !*submitTBR && (r.Resolved == nil || !*r.Resolved) {
return errors.New("Not submitting as the review has not yet been accepted.")
}
target := r.Request.TargetRef
source := r.Request.ReviewRef
repo.VerifyGitRefOrDie(target)
repo.VerifyGitRefOrDie(source)
if !repo.IsAncestor(target, source) {
return errors.New("Refusing to submit a non-fast-forward review. First merge the target ref.")
}
repo.SwitchToRef(target)
if *submitMerge {
repo.MergeRef(source, false)
} else if *submitRebase {
repo.RebaseRef(source)
} else {
repo.MergeRef(source, true)
}
return nil
}
示例6: submitReview
// Submit the current code review request.
//
// The "args" parameter contains all of the command line arguments that followed the subcommand.
func submitReview(repo repository.Repo, args []string) error {
submitFlagSet.Parse(args)
args = submitFlagSet.Args()
if *submitMerge && *submitRebase {
return errors.New("Only one of --merge or --rebase is allowed.")
}
var r *review.Review
var err error
if len(args) > 1 {
return errors.New("Only accepting a single review is supported.")
}
if len(args) == 1 {
r, err = review.Get(repo, args[0])
} else {
r, err = review.GetCurrent(repo)
}
if err != nil {
return fmt.Errorf("Failed to load the review: %v\n", err)
}
if r == nil {
return errors.New("There is no matching review.")
}
if r.Submitted {
return errors.New("The review has already been submitted.")
}
if !*submitTBR && (r.Resolved == nil || !*r.Resolved) {
return errors.New("Not submitting as the review has not yet been accepted.")
}
target := r.Request.TargetRef
if err := repo.VerifyGitRef(target); err != nil {
return err
}
source, err := r.GetHeadCommit()
if err != nil {
return err
}
isAncestor, err := repo.IsAncestor(target, source)
if err != nil {
return err
}
if !isAncestor {
return errors.New("Refusing to submit a non-fast-forward review. First merge the target ref.")
}
if !(*submitRebase || *submitMerge || *submitFastForward) {
submitStrategy, err := repo.GetSubmitStrategy()
if err != nil {
return err
}
if submitStrategy == "merge" && !*submitRebase && !*submitFastForward {
*submitMerge = true
}
if submitStrategy == "rebase" && !*submitMerge && !*submitFastForward {
*submitRebase = true
}
if submitStrategy == "fast-forward" && !*submitRebase && !*submitMerge {
*submitFastForward = true
}
}
if *submitRebase {
if err := r.Rebase(*submitArchive); err != nil {
return err
}
source, err = r.GetHeadCommit()
if err != nil {
return err
}
}
if err := repo.SwitchToRef(target); err != nil {
return err
}
if *submitMerge {
submitMessage := fmt.Sprintf("Submitting review %.12s", r.Revision)
return repo.MergeRef(source, false, submitMessage, r.Request.Description)
} else {
return repo.MergeRef(source, true)
}
}