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