Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit 6c95b73

Browse files
committed
feat: Add functionality for reading the .dod.yml file. First commit using the tool.
1 parent 39a233b commit 6c95b73

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

.dod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# --- Optional Issue Tracker Integration ---
1515
# If true, the check-commit tool will require the --issue <ID> flag
1616
# to be used with the commit command, ensuring all work is traceable.
17-
issue_reference_required: true
17+
issue_reference_required: false
1818

1919
checklist:
2020
# --- Code Quality & Testing (High-Impact Checks) ---

Cargo.lock

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ clap = { version = "4.5.41", features = ["derive"] }
1515
thiserror = "2.0.12"
1616
anyhow = "1.0.98"
1717
colored = "3.0.0"
18+
serde_yaml = "0.9.33"
19+
serde = { version = "1.0.219", features = ["derive"] }
1820

1921
[dev-dependencies]
2022
serial_test = "3.2.0"

src/main.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
mod cli;
22
mod git;
3+
use serde::Deserialize;
4+
use std::fs;
5+
use anyhow::{Result, Context};
36
use clap::Parser;
47
use colored::Colorize;
58

9+
#[derive(Debug, Deserialize)]
10+
struct DodConfig {
11+
issue_reference_required: Option<bool>,
12+
checklist: Vec<String>,
13+
}
14+
15+
fn read_dod_config() -> Result<DodConfig> {
16+
let content = fs::read_to_string(".dod.yml")
17+
.context("Failed to read .dod.yml")?;
18+
let config: DodConfig = serde_yaml::from_str(&content)
19+
.context("Failed to parse .dod.yml")?;
20+
Ok(config)
21+
}
22+
623
fn main() -> anyhow::Result<()> {
724
let cli = cli::Cli::parse();
25+
let config = read_dod_config()?;
26+
if !config.checklist.is_empty() {
27+
println!("Checklist items:");
28+
for item in config.checklist {
29+
println!("- {}", item);
30+
}
31+
} else {
32+
println!("{}", "No checklist items defined.".yellow());
33+
}
34+
835
match cli.command {
936
cli::Commands::Status => {
1037
println!("--- Checking Git status ---");
@@ -13,6 +40,10 @@ fn main() -> anyhow::Result<()> {
1340
}
1441
cli::Commands::Commit { r#type, scope, message} => {
1542
println!("--- Committing changes ---");
43+
if config.issue_reference_required.unwrap_or(false) {
44+
println!("{}", "Issue reference is required for commits.".red());
45+
return Err(anyhow::anyhow!("Issue reference required"));
46+
}
1647
let scope_part = scope.map_or("".to_string(), |s| format!("({})", s));
1748
let header = format!("{}{}: {}", r#type, scope_part, message);
1849
let commit_message = format!("{}", header);

0 commit comments

Comments
 (0)