Exemplo n.º 1
0
// WriteNewComments takes a list of review comments read from GitHub, and writes to the repo any that are new.
//
// The passed in logChan variable is used as our intermediary for logging, and allows us to
// use the same logic for logging messages in either our CLI or our App Engine apps, even though
// the two have different logging frameworks.
func WriteNewComments(r review.Review, repo repository.Repo, logChan chan<- string) error {
	existingComments := comment.ParseAllValid(repo.GetNotes(comment.Ref, r.Revision))
	for _, commentThread := range r.Comments {
		commentNote, err := commentThread.Comment.Write()
		if err != nil {
			return err
		}
		missing := true
		for _, existing := range existingComments {
			if CommentsOverlap(existing, commentThread.Comment) {
				missing = false
			}
		}
		if missing {
			logChan <- fmt.Sprintf("Found a new comment: %q", string(commentNote))
			if err := repo.AppendNote(comment.Ref, r.Revision, commentNote); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemplo n.º 2
0
// loadComments reads in the log-structured sequence of comments for a review,
// and then builds the corresponding tree-structured comment threads.
func (r *Review) loadComments() []CommentThread {
	commentNotes := r.Repo.GetNotes(comment.Ref, r.Revision)
	commentsByHash := comment.ParseAllValid(commentNotes)
	return buildCommentThreads(commentsByHash)
}
Exemplo n.º 3
0
// loadComments reads in the log-structured sequence of comments for a review,
// and then builds the corresponding tree-structured comment threads.
func (r *Summary) loadComments(commentNotes []repository.Note) []CommentThread {
	commentsByHash := comment.ParseAllValid(commentNotes)
	return buildCommentThreads(commentsByHash)
}