2024-09-17 18:03:50 +01:00
|
|
|
use anyhow::Context;
|
|
|
|
|
2024-09-17 16:48:09 +01:00
|
|
|
fn main() -> anyhow::Result<()> {
|
|
|
|
println!("Forgejo TODO Checker!");
|
|
|
|
|
2024-09-17 18:44:15 +01:00
|
|
|
let ci_repo = std::env::var("GITHUB_REPOSITORY").context("GITHUB_REPOSITORY")?;
|
|
|
|
let ci_server_url = std::env::var("GITHUB_SERVER_URL").context("GITHUB_SERVER_URL")?;
|
|
|
|
let ci_repo_url = format!("{ci_server_url}/{ci_repo}");
|
2024-09-17 18:03:50 +01:00
|
|
|
|
|
|
|
// optional arg for private repos
|
|
|
|
let repo_token = std::env::var("REPO_TOKEN").ok();
|
|
|
|
|
|
|
|
// Regex to match a todo or fixme comment
|
|
|
|
let prefix = regex::Regex::new(r"(#|//)\s*(TODO|FIXME)").context("prefix regex")?;
|
|
|
|
// Regex to match the rest of the line to find an issue number
|
|
|
|
let issue =
|
|
|
|
regex::Regex::new(r"( |)(\(|\(#)(?P<ISSUE_NUMBER>\d+)(\))").context("issue regex")?;
|
|
|
|
|
2024-09-17 18:44:15 +01:00
|
|
|
println!("[ci_repo:{ci_repo}][ci_repo_url:{ci_repo_url}][repo_token:{repo_token:?}][prefix:{prefix}][issue:{issue}]");
|
2024-09-17 18:03:50 +01:00
|
|
|
|
2024-09-17 16:48:09 +01:00
|
|
|
// list files in current directory to get a feel for what we have access to
|
|
|
|
std::fs::read_dir(".")?
|
|
|
|
.filter_map(Result::ok)
|
|
|
|
.map(|e| e.path())
|
|
|
|
.for_each(|e| println!("{e:?}"));
|
|
|
|
|
|
|
|
Ok(())
|
2024-09-17 16:26:32 +01:00
|
|
|
}
|