nit(#1141): suppress :line in text output when comment has no line number

This commit is contained in:
damocles 2026-06-03 16:01:32 +02:00
commit 374e53d13e

View file

@ -145,13 +145,12 @@ fn list_reviews(client: &Client, number: u64) -> Result<()> {
if id > 0 {
for c in &fetch_inline_comments(client, repo, number, id) {
let path = c.get("path").and_then(Value::as_str).unwrap_or("?");
let line = c
.get("line")
.and_then(Value::as_u64)
.map(|n| n.to_string())
.unwrap_or_else(|| "?".to_string());
let cbody = c.get("body").and_then(Value::as_str).unwrap_or("").trim();
println!(" [{path}:{line}] {cbody}");
// PR-level comments have no line; omit `:line` when absent.
match c.get("line").and_then(Value::as_u64) {
Some(line) => println!(" [{path}:{line}] {cbody}"),
None => println!(" [{path}] {cbody}"),
}
}
}
println!();