From acda4f6c75ecc52cf2dbabecc6a9f11fa6f34dd8 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 15 Sep 2020 23:52:24 +0200 Subject: main.rs: Fix 101-removed-todo-lines-not-included test The `new_lineno()` is `None` when the line was removed. Ignoring removed lines allows us to leave out removed TODOs. --- src/main.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7839c2d..6dd3e91 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,15 +30,17 @@ fn main() { // std::str::from_utf8(line.content()).unwrap(), // ); - let l = std::str::from_utf8(line.content()).unwrap(); - - if l.contains("TODO") { - println!( - "{}:{}:{}", - delta.new_file().path().unwrap().display(), - line.new_lineno().unwrap(), - l, - ); + if let Some(line_number) = line.new_lineno() { + let l = std::str::from_utf8(line.content()).unwrap(); + + if l.contains("TODO") { + println!( + "{}:{}:{}", + delta.new_file().path().unwrap().display(), + line_number, + l, + ); + } } true -- cgit v1.2.3