Skip to main content

tga_collect/
lib.rs

1//! # tga-collect
2//!
3//! Stage 1 of the `trusty-git-analytics` pipeline: extract commit data from
4//! local git repositories and correlate it with external systems (GitHub
5//! pull requests, JIRA tickets, developer identity records). All output is
6//! persisted via [`tga_core::db::Database`].
7//!
8//! ## Modules
9//!
10//! - [`git`] — commit extraction via libgit2
11//! - [`identity`] — author identity resolution (exact + fuzzy)
12//! - [`github`] — GitHub REST client (PRs)
13//! - [`jira`] — JIRA REST client (issues)
14//! - [`collector`] — end-to-end pipeline orchestrator
15//! - [`errors`] — crate-level error type ([`CollectError`])
16
17#![warn(missing_docs)]
18
19pub mod collector;
20pub mod errors;
21pub mod git;
22pub mod github;
23pub mod identity;
24pub mod jira;
25
26pub use collector::{CollectionPipeline, CollectionStats};
27pub use errors::{CollectError, Result};
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32    use tga_core::config::{Config, RepositoryConfig};
33
34    #[test]
35    fn git_collector_rejects_missing_path() {
36        let cfg = RepositoryConfig {
37            path: "/definitely/does/not/exist/here".into(),
38            ..Default::default()
39        };
40        let err = git::GitCollector::new(&cfg).expect_err("should fail");
41        match err {
42            CollectError::Config(msg) => assert!(msg.contains("does not exist"), "msg: {msg}"),
43            other => panic!("unexpected error: {other:?}"),
44        }
45    }
46
47    #[test]
48    fn git_collector_rejects_non_repo_path() {
49        // /tmp exists but is not a git repo.
50        let cfg = RepositoryConfig {
51            path: std::env::temp_dir(),
52            ..Default::default()
53        };
54        let err = git::GitCollector::new(&cfg).expect_err("should fail");
55        assert!(matches!(err, CollectError::Git(_)));
56    }
57
58    #[test]
59    fn pipeline_constructs_with_default_config() {
60        let cfg = Config::default();
61        let _pipeline = CollectionPipeline::new(cfg);
62    }
63}