aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-09-15 23:52:24 +0200
committerTeddy Wing2020-09-15 23:52:24 +0200
commitacda4f6c75ecc52cf2dbabecc6a9f11fa6f34dd8 (patch)
treebe4a24ec32c3fbd86817d8c92121b6a1566cd0f2
parent1e73d3db263c9986ff94a3ef3cf258ed5b8b32e9 (diff)
downloadgit-todo-acda4f6c75ecc52cf2dbabecc6a9f11fa6f34dd8.tar.bz2
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.
-rw-r--r--src/main.rs20
1 files 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