Пример #1
0
func getSummaryFromNotes(repo repository.Repo, revision string, requestNotes, commentNotes []repository.Note) (*Summary, error) {
	requests := request.ParseAllValid(requestNotes)
	if requests == nil {
		return nil, nil
	}
	sort.Stable(requestsByTimestamp(requests))
	reviewSummary := Summary{
		Repo:        repo,
		Revision:    revision,
		Request:     requests[len(requests)-1],
		AllRequests: requests,
	}
	reviewSummary.Comments = reviewSummary.loadComments(commentNotes)
	reviewSummary.Resolved = updateThreadsStatus(reviewSummary.Comments)
	return &reviewSummary, nil
}
Пример #2
0
// Get returns the specified code review.
//
// If no review request exists, the returned review is nil.
func Get(revision string) *Review {
	requestNotes := repository.GetNotes(request.Ref, revision)
	requests := request.ParseAllValid(requestNotes)
	if requests == nil {
		return nil
	}
	review := Review{
		Revision: revision,
		Request:  requests[len(requests)-1],
	}
	review.Comments = review.loadComments()
	review.Resolved = updateThreadsStatus(review.Comments)
	review.Submitted = repository.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
0
// 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
0
// 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
}