From 36fb1b9a2d3763cd23e328651bb5586feda45ab9 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 15:45:34 +0000 Subject: [PATCH] Initial upload: GitPulse - Developer Productivity Analyzer CLI tool --- src/models/mod.rs | 198 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 src/models/mod.rs diff --git a/src/models/mod.rs b/src/models/mod.rs new file mode 100644 index 0000000..97fc112 --- /dev/null +++ b/src/models/mod.rs @@ -0,0 +1,198 @@ +pub mod commit; +pub mod author; +pub mod file; +pub mod time_series; + +pub use commit::CommitData; +pub use author::AuthorStats; +pub use file::FileStats; +pub use time_series::{TimeSeriesData, TimeBucket}; + +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RepositoryInfo { + pub path: String, + pub branch: Option, + pub remote_url: Option, + pub total_commits: usize, + pub total_authors: usize, + pub repository_age_days: i64, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CommitFrequency { + pub total_commits: usize, + pub commits_per_day: f64, + pub commits_per_week: f64, + pub commits_per_month: f64, + pub busiest_day: String, + pub busiest_day_count: usize, + pub quietest_day: String, + pub quietest_day_count: usize, + pub day_distribution: HashMap, + pub hour_distribution: HashMap, +} + +impl Default for CommitFrequency { + fn default() -> Self { + Self { + total_commits: 0, + commits_per_day: 0.0, + commits_per_week: 0.0, + commits_per_month: 0.0, + busiest_day: String::new(), + busiest_day_count: 0, + quietest_day: String::new(), + quietest_day_count: 0, + day_distribution: HashMap::new(), + hour_distribution: HashMap::new(), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CodeChurn { + pub total_lines_added: usize, + pub total_lines_removed: usize, + pub net_change: i64, + pub average_commit_size: f64, + pub largest_commit: Option, + pub top_churn_files: Vec, + pub additions_by_day: HashMap, + pub removals_by_day: HashMap, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CommitChange { + pub oid: String, + pub message: String, + pub author: String, + pub timestamp: String, + pub lines_added: usize, + pub lines_removed: usize, + pub net_change: i64, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct FileChange { + pub path: String, + pub lines_added: usize, + pub lines_removed: usize, + pub net_change: i64, + pub commit_count: usize, +} + +impl Default for CodeChurn { + fn default() -> Self { + Self { + total_lines_added: 0, + total_lines_removed: 0, + net_change: 0, + average_commit_size: 0.0, + largest_commit: None, + top_churn_files: Vec::new(), + additions_by_day: HashMap::new(), + removals_by_day: HashMap::new(), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ContributorStats { + pub total_contributors: usize, + pub top_contributors: Vec, + pub contributions_by_author: HashMap, +} + +impl Default for ContributorStats { + fn default() -> Self { + Self { + total_contributors: 0, + top_contributors: Vec::new(), + contributions_by_author: HashMap::new(), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RefactoringActivity { + pub total_renames: usize, + pub total_copies: usize, + pub refactoring_score: f64, + pub renamed_files: Vec, + pub refactoring_hotspots: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RenameInfo { + pub old_path: String, + pub new_path: String, + pub commit_oid: String, + pub commit_message: String, + pub similarity: f64, + pub timestamp: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RefactoringHotspot { + pub file_path: String, + pub rename_count: usize, + pub last_rename: String, +} + +impl Default for RefactoringActivity { + fn default() -> Self { + Self { + total_renames: 0, + total_copies: 0, + refactoring_score: 0.0, + renamed_files: Vec::new(), + refactoring_hotspots: Vec::new(), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct AnalysisResult { + pub repository: RepositoryInfo, + pub time_range: TimeRange, + pub commit_frequency: CommitFrequency, + pub code_churn: CodeChurn, + pub contributors: ContributorStats, + pub refactoring: RefactoringActivity, + pub time_series: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TimeRange { + pub start: String, + pub end: String, + pub days: u32, +} + +impl Default for AnalysisResult { + fn default() -> Self { + Self { + repository: RepositoryInfo { + path: String::new(), + branch: None, + remote_url: None, + total_commits: 0, + total_authors: 0, + repository_age_days: 0, + }, + time_range: TimeRange { + start: String::new(), + end: String::new(), + days: 0, + }, + commit_frequency: CommitFrequency::default(), + code_churn: CodeChurn::default(), + contributors: ContributorStats::default(), + refactoring: RefactoringActivity::default(), + time_series: Vec::new(), + } + } +}