feat: log any invalid/closed markers and exit if any found
All checks were successful
Test / test (push) Successful in 8s
All checks were successful
Test / test (push) Successful in 8s
This commit is contained in:
parent
d161d0104e
commit
57f88bb832
2 changed files with 23 additions and 6 deletions
20
src/main.rs
20
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
use anyhow::Result;
|
use anyhow::{bail, Result};
|
||||||
use init::init_config;
|
use init::init_config;
|
||||||
use issues::fetch_open_issues;
|
use issues::fetch_open_issues;
|
||||||
use scanner::find_markers;
|
use scanner::find_markers;
|
||||||
|
@ -22,14 +22,22 @@ async fn run(net: kxio::network::Network) -> Result<()> {
|
||||||
println!("Forgejo TODO Checker!");
|
println!("Forgejo TODO Checker!");
|
||||||
|
|
||||||
let config = init_config(net)?;
|
let config = init_config(net)?;
|
||||||
|
|
||||||
let issues = fetch_open_issues(&config).await?;
|
let issues = fetch_open_issues(&config).await?;
|
||||||
|
|
||||||
let markers = find_markers(&config, issues)?;
|
let markers = find_markers(&config, issues)?;
|
||||||
println!("{markers}");
|
|
||||||
|
|
||||||
// TODO: loop over markers, logging any that are invalid or closed.
|
let mut errors = false;
|
||||||
// TODO: if we logged any, then exit as and error
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
use crate::{issues::Issue, model::Line};
|
use crate::{issues::Issue, model::Line};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -42,6 +44,13 @@ impl Markers {
|
||||||
self.markers.push(marker);
|
self.markers.push(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Deref for Markers {
|
||||||
|
type Target = Vec<Marker>;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.markers
|
||||||
|
}
|
||||||
|
}
|
||||||
impl std::fmt::Display for Markers {
|
impl std::fmt::Display for Markers {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
for marker in self.markers.iter() {
|
for marker in self.markers.iter() {
|
||||||
|
|
Loading…
Reference in a new issue