forgejo-todo-checker/src/main.rs

45 lines
1.1 KiB
Rust
Raw Normal View History

2024-09-18 11:55:33 +01:00
//
use anyhow::{bail, Result};
2024-09-19 19:12:41 +01:00
use init::init_config;
2024-09-20 07:23:36 +01:00
use issues::fetch_open_issues;
use scanner::{find_markers, DefaultFileScanner};
2024-09-18 11:55:33 +01:00
2024-09-19 19:12:41 +01:00
mod init;
2024-09-20 07:23:36 +01:00
mod issues;
2024-09-18 11:55:33 +01:00
mod model;
mod patterns;
2024-09-19 19:12:41 +01:00
mod scanner;
2024-09-19 19:32:15 +01:00
#[cfg(test)]
mod tests;
2024-09-20 07:23:36 +01:00
#[tokio::main]
#[cfg(not(tarpaulin_include))]
2024-09-20 07:23:36 +01:00
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
Ok(run(kxio::network::Network::new_real()).await?)
2024-09-19 20:37:23 +01:00
}
2024-09-20 07:23:36 +01:00
async fn run(net: kxio::network::Network) -> Result<()> {
println!("Forgejo TODO Checker!");
2024-09-20 07:23:36 +01:00
let config = init_config(net)?;
let issues = fetch_open_issues(&config).await?;
let markers = find_markers(&config, issues, &DefaultFileScanner)?;
let mut errors = false;
for marker in (*markers).iter() {
match marker {
model::Marker::Closed(_, _) | model::Marker::Invalid(_) => {
println!("{marker}");
errors = true;
}
model::Marker::Unmarked | model::Marker::Valid(_, _) => {}
}
}
if errors {
bail!("Invalid or closed TODO/FIXMEs found")
}
Ok(())
}