MCPcopy Create free account
hub / github.com/google/git-appraise / fixMutableThread

Function fixMutableThread

review/review.go:197–221  ·  view source on GitHub ↗

fixMutableThread is a helper method to finalize a mutableThread struct (partially constructed comment thread) as a CommentThread struct (fully constructed comment thread).

(mutableThread *mutableThread)

Source from the content-addressed store, hash-verified

195// (partially constructed comment thread) as a CommentThread struct
196// (fully constructed comment thread).
197func fixMutableThread(mutableThread *mutableThread) CommentThread {
198 var children []CommentThread
199 edited := len(mutableThread.Edits) > 0
200 for _, mutableChild := range mutableThread.Children {
201 child := fixMutableThread(mutableChild)
202 if (!edited) && child.Edited {
203 edited = true
204 }
205 children = append(children, child)
206 }
207 comment := &mutableThread.Comment
208 if len(mutableThread.Edits) > 0 {
209 sort.Stable(commentsByTimestamp(mutableThread.Edits))
210 comment = mutableThread.Edits[len(mutableThread.Edits)-1]
211 }
212
213 return CommentThread{
214 Hash: mutableThread.Hash,
215 Comment: *comment,
216 Original: &mutableThread.Comment,
217 Edits: mutableThread.Edits,
218 Children: children,
219 Edited: edited,
220 }
221}
222
223// This function builds the comment thread tree from the log-based list of comments.
224//

Callers 1

buildCommentThreadsFunction · 0.85

Calls 1

commentsByTimestampTypeAlias · 0.85

Tested by

no test coverage detected