Skip to content

Commit 93529a8

Browse files
committed
Add basic project structure
1 parent f394d49 commit 93529a8

File tree

8 files changed

+182
-0
lines changed

8 files changed

+182
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
target/
2+
Cargo.lock
3+
*.swp
4+
*.swo
5+
*~
6+
.DS_Store

Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "git-reports"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["MadKoding"]
6+
description = "Automated Git analytics engine that generates work summaries from repository activity"
7+
license = "MIT"
8+
repository = "https://github.com/madkoding/git-reports"
9+
10+
[dependencies]
11+
clap = { version = "4.4", features = ["derive"] }
12+
chrono = { version = "0.4", features = ["serde"] }
13+
serde = { version = "1.0", features = ["derive"] }
14+
serde_json = "1.0"
15+
git2 = "0.18"
16+
tokio = { version = "1", features = ["full"] }
17+
18+
[lib]
19+
name = "git_reports"
20+
path = "src/lib.rs"
21+
22+
[[bin]]
23+
name = "git-reports"
24+
path = "src/main.rs"

src/analysis/commit.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Debug, Clone, Serialize, Deserialize)]
4+
pub struct Commit {
5+
pub id: String,
6+
pub message: String,
7+
pub author: String,
8+
pub date: String,
9+
pub files_changed: u32,
10+
pub insertions: u32,
11+
pub deletions: u32,
12+
}
13+
14+
impl Commit {
15+
pub fn new(id: String, message: String, author: String, date: String) -> Self {
16+
Self {
17+
id,
18+
message,
19+
author,
20+
date,
21+
files_changed: 0,
22+
insertions: 0,
23+
deletions: 0,
24+
}
25+
}
26+
}

src/analysis/contributor.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Debug, Clone, Serialize, Deserialize)]
4+
pub struct Contributor {
5+
pub name: String,
6+
pub email: String,
7+
pub commits: u32,
8+
pub insertions: u32,
9+
pub deletions: u32,
10+
pub first_commit: Option<String>,
11+
pub last_commit: Option<String>,
12+
}
13+
14+
impl Contributor {
15+
pub fn new(name: String, email: String) -> Self {
16+
Self {
17+
name,
18+
email,
19+
commits: 0,
20+
insertions: 0,
21+
deletions: 0,
22+
first_commit: None,
23+
last_commit: None,
24+
}
25+
}
26+
}

src/analysis/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub mod commit;
2+
pub mod contributor;
3+
pub mod report;
4+
5+
pub use commit::*;
6+
pub use contributor::*;
7+
pub use report::*;

src/analysis/report.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
use serde::{Deserialize, Serialize};
2+
use super::{Commit, Contributor};
3+
4+
#[derive(Debug, Clone, Serialize, Deserialize)]
5+
pub struct Report {
6+
pub repository: String,
7+
pub period: String,
8+
pub total_commits: u32,
9+
pub total_contributors: u32,
10+
pub total_insertions: u32,
11+
pub total_deletions: u32,
12+
pub commits: Vec<Commit>,
13+
pub contributors: Vec<Contributor>,
14+
pub generated_at: String,
15+
}
16+
17+
impl Report {
18+
pub fn new(repository: String, period: String) -> Self {
19+
Self {
20+
repository,
21+
period,
22+
total_commits: 0,
23+
total_contributors: 0,
24+
total_insertions: 0,
25+
total_deletions: 0,
26+
commits: Vec::new(),
27+
contributors: Vec::new(),
28+
generated_at: chrono::Utc::now().to_rfc3339(),
29+
}
30+
}
31+
}
32+
33+
#[cfg(test)]
34+
mod tests {
35+
use super::*;
36+
37+
#[test]
38+
fn test_report_creation() {
39+
let report = Report::new("test-repo".to_string(), "week".to_string());
40+
assert_eq!(report.repository, "test-repo");
41+
assert_eq!(report.period, "week");
42+
assert_eq!(report.total_commits, 0);
43+
}
44+
45+
#[test]
46+
fn test_contributor_creation() {
47+
let contributor = Contributor::new("Test User".to_string(), "test@example.com".to_string());
48+
assert_eq!(contributor.name, "Test User");
49+
assert_eq!(contributor.commits, 0);
50+
}
51+
52+
#[test]
53+
fn test_commit_creation() {
54+
let commit = Commit::new(
55+
"abc123".to_string(),
56+
"Test commit".to_string(),
57+
"Test Author".to_string(),
58+
"2024-01-01".to_string(),
59+
);
60+
assert_eq!(commit.id, "abc123");
61+
assert_eq!(commit.message, "Test commit");
62+
}
63+
}

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod analysis;
2+
3+
pub use analysis::*;

src/main.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use clap::Parser;
2+
3+
#[derive(Parser, Debug)]
4+
#[command(name = "git-reports")]
5+
#[command(about = "Automated Git analytics engine for work summaries", long_about = None)]
6+
struct Args {
7+
/// Path to the Git repository
8+
#[arg(short, long, default_value = ".")]
9+
repo: String,
10+
11+
/// Output file path (JSON)
12+
#[arg(short, long)]
13+
output: Option<String>,
14+
15+
/// Time period: week, month, all
16+
#[arg(short, long, default_value = "week")]
17+
period: String,
18+
}
19+
20+
fn main() {
21+
let args = Args::parse();
22+
println!("Git Reports - Analyzing repository: {}", args.repo);
23+
println!("Period: {}", args.period);
24+
25+
// TODO: Implement Git analysis
26+
println!("Analysis complete!");
27+
}

0 commit comments

Comments
 (0)