Initial upload: git-insights-cli with CI/CD workflow
This commit is contained in:
35
src/utils/config.py
Normal file
35
src/utils/config.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(config_path: Optional[str] = None) -> Dict[str, Any]:
|
||||||
|
"""Load configuration from file or use defaults."""
|
||||||
|
if config_path and os.path.exists(config_path):
|
||||||
|
with open(config_path, "r") as f:
|
||||||
|
return yaml.safe_load(f) or {}
|
||||||
|
|
||||||
|
default_paths = [
|
||||||
|
".git-insights/config.yaml",
|
||||||
|
os.path.expanduser("~/.git-insights/config.yaml"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in default_paths:
|
||||||
|
if os.path.exists(path):
|
||||||
|
with open(path, "r") as f:
|
||||||
|
return yaml.safe_load(f) or {}
|
||||||
|
|
||||||
|
return get_default_config()
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_config() -> Dict[str, Any]:
|
||||||
|
"""Return default configuration."""
|
||||||
|
return {
|
||||||
|
"repository_path": ".",
|
||||||
|
"analysis_days": 30,
|
||||||
|
"output_format": "json",
|
||||||
|
"churn_threshold": 500,
|
||||||
|
"risky_commit_threshold": 500,
|
||||||
|
"merge_commit_flag": True,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user