fix: use pr-index based comment numbering in markdown
This commit is contained in:
@@ -22,9 +22,10 @@ fn render_body(body: &str) -> String {
|
||||
format!("{fence}md\n{body}\n{fence}\n")
|
||||
}
|
||||
|
||||
fn render_thread(thread_index: usize, thread: &CommentThread) -> String {
|
||||
fn render_thread(pr_index: i64, comment_seq: usize, thread: &CommentThread) -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str(&format!("### Comment {}.1\n", thread_index));
|
||||
let comment_number = format!("{pr_index}.{comment_seq}");
|
||||
out.push_str(&format!("### Comment {comment_number}\n"));
|
||||
if let Some(file_path) = &thread.file_path {
|
||||
if let Some(line) = thread.line {
|
||||
out.push_str(&format!("{file_path}:{line}\n"));
|
||||
@@ -36,7 +37,7 @@ fn render_thread(thread_index: usize, thread: &CommentThread) -> String {
|
||||
out.push_str(&render_body(&thread.root_comment.body));
|
||||
|
||||
for (reply_index, reply) in thread.replies.iter().enumerate() {
|
||||
let reply_number = format!("{thread_index}.1.{}", reply_index + 1);
|
||||
let reply_number = format!("{comment_number}.{}", reply_index + 1);
|
||||
out.push_str(&format!("\n### Reply {reply_number}\n"));
|
||||
out.push_str(&format!("{}:\n", reply.user));
|
||||
out.push_str(&render_body(&reply.body));
|
||||
@@ -101,7 +102,7 @@ pub fn render_markdown(doc: &PrReviewDocument) -> String {
|
||||
}
|
||||
|
||||
for (thread_index, thread) in doc.threads.iter().enumerate() {
|
||||
out.push_str(&render_thread(thread_index + 1, thread));
|
||||
out.push_str(&render_thread(doc.meta.pr_index, thread_index + 1, thread));
|
||||
out.push('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user