nit(#1141): suppress :line in text output when comment has no line number
This commit is contained in:
parent
b39967eb7a
commit
374e53d13e
1 changed files with 5 additions and 6 deletions
|
|
@ -145,13 +145,12 @@ fn list_reviews(client: &Client, number: u64) -> Result<()> {
|
||||||
if id > 0 {
|
if id > 0 {
|
||||||
for c in &fetch_inline_comments(client, repo, number, id) {
|
for c in &fetch_inline_comments(client, repo, number, id) {
|
||||||
let path = c.get("path").and_then(Value::as_str).unwrap_or("?");
|
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();
|
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!();
|
println!();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue