Skip to content

@maat-tools/collector-git

Provides

git_commits · git_file_changes

Collects git history facts — commits and file changes — for use by git-based rules and insights.

Facts Provided

FactTypeDescription
git_commitsGitCommit[]One entry per commit: hash, author, email, ISO date, subject
git_file_changesGitFileChange[]One entry per file touched per commit: path, status, optional old path for renames

GitCommit

ts
type GitCommit = {
	hash: string;
	author: string;
	authorEmail: string;
	date: string;        // ISO 8601
	subject: string;
};

GitFileChange

ts
type GitFileChange = {
	hash: string;
	path: string;
	status: GitFileStatus; // Added | Modified | Deleted | Renamed | Copied
	oldPath?: string;      // present for Renamed and Copied
};

Options

ts
type GitInput = {
	repoPath?: string;
	sinceDays?: number;
	maxCommits?: number;
};
OptionDefaultMeaning
repoPathprocess.cwd()Path to the git repository root
sinceDaysCollect only commits from the last N days. Converted to an ISO date before being passed to git
maxCommitsLimits history depth via git --max-count=

Usage

ts
export default defineConfig({
	collectors: [
		['@maat-tools/collector-git', { sinceDays: 90 }],
	],
});

With a commit cap:

ts
export default defineConfig({
	collectors: [
		['@maat-tools/collector-git', {
			sinceDays: 90,
			maxCommits: 1000,
		}],
	],
});

Notes

  • The collector shell-invokes git log in the configured repoPath. Git must be available in PATH.
  • Renamed files carry oldPath so rules can follow file identity across renames.
  • The collector returns all history matching the filter. Rules are responsible for applying their own time-window logic on top of the collected facts.