Hamburger Cross Icon
Git Collector - Lunar Collector

Git Collector

Collector Beta Code Analysis

Aggregates configuration data for git-ecosystem tooling that lives in the repository: pre-commit hooks, gitattributes rules, and submodule definitions. Distinct from `.vcs.*` (hosted-VCS data like branch protection, PRs).

Add git to your lunar-config.yml:
uses: github://earthly/lunar-lib/collectors/git@v1.0.5

What This Integration Collects

This integration includes 3 collectors that gather metadata from your systems.

Collector code

pre-commit

Scans the repository for a pre-commit configuration file at .pre-commit-config.yaml (or .yml variant). Parses the YAML to extract the configured repos[] (each with repo, rev, hooks[]), a flattened list of hook IDs, and the optional ci.skip list. Writes structured data to .git.pre_commit.

pre-commit git hooks lint secret scan code quality developer tooling
Book a demo
Collector code

gitattributes

Detects .gitattributes in the repository root. Parses each rule to classify patterns by attribute (text/eol for EOL normalization, filter=lfs for Git LFS, binary for binary patterns, export-ignore for archive exclusion). Writes to .git.attributes.

gitattributes git lfs eol normalization line endings repository hygiene
Book a demo
Collector code

gitmodules

Detects .gitmodules in the repository root. Parses each [submodule "<name>"] block to extract path, url, and the optional branch field (set when a submodule tracks a floating ref via git submodule update --remote). Writes to .git.submodules.

gitmodules git submodules vendoring supply chain
Book a demo

How Collectors Fit into Lunar

Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.

Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.

Learn How Lunar Works
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "git": {
    "pre_commit": {
      "valid": true,
      "path": ".pre-commit-config.yaml",
      "repos": [
        {
          "repo": "https://github.com/pre-commit/pre-commit-hooks",
          "rev": "v4.5.0",
          "hooks": [
            {"id": "trailing-whitespace"},
            {"id": "end-of-file-fixer"}
          ]
        },
        {
          "repo": "https://github.com/gitleaks/gitleaks",
          "rev": "v8.18.0",
          "hooks": [
            {"id": "gitleaks"}
          ]
        }
      ],
      "hook_ids": ["trailing-whitespace", "end-of-file-fixer", "gitleaks"],
      "hook_count": 3,
      "repo_count": 2,
      "ci_skip": [],
      "all_pinned": true
    },
    "attributes": {
      "valid": true,
      "path": ".gitattributes",
      "rules_count": 8,
      "lfs_patterns": ["*.psd", "*.zip"],
      "binary_patterns": ["*.exe"],
      "eol_normalized": true,
      "export_ignore_patterns": [".github/", "tests/"]
    },
    "submodules": {
      "valid": true,
      "path": ".gitmodules",
      "modules": [
        {
          "name": "vendor/foo",
          "path": "vendor/foo",
          "url": "https://github.com/example/foo.git",
          "branch": null
        },
        {
          "name": "vendor/bar",
          "path": "vendor/bar",
          "url": "https://github.com/example/bar.git",
          "branch": "main"
        }
      ]
    }
  }
}

Configuration

Configure this collector in your lunar-config.yml.

Inputs

Input Required Default Description
pre_commit_paths Optional .pre-commit-config.yaml,.pre-commit-config.yml Comma-separated list of pre-commit config file paths to check (first match wins)
gitattributes_paths Optional .gitattributes Comma-separated list of .gitattributes paths to check (first match wins)
gitmodules_paths Optional .gitmodules Comma-separated list of .gitmodules paths to check (first match wins)

Documentation

View on GitHub

Git Collector

Collect git-ecosystem configuration data — pre-commit hooks, gitattributes, and submodules.

Overview

This collector parses repository-local git-ecosystem configuration into structured Component JSON. It is distinct from the .vcs.* namespace (hosted-VCS data: GitHub branch protection, PRs); .git.* is for the local git tool's config and the hooks/history it manages. The three sub-collectors target pre-commit, .gitattributes (LFS / EOL / export-ignore rules), and .gitmodules (submodule definitions). Data feeds the paired git policy.

Collected Data

When no relevant config file is found for a sub-collector, this collector writes nothing under that key — object presence at .git.<sub> is itself the signal that the technology is configured. See collector-reference.md § Write Nothing When Technology Not Detected.

This collector writes to the following Component JSON paths (each rooted at .git.<sub>, present only when the sub-collector finds data):

Path Type Description
.git.pre_commit.valid boolean Whether the YAML config has valid syntax
.git.pre_commit.path string Path to the config file
.git.pre_commit.repos[] array Configured repos — each with repo, rev, and hooks[] (objects with id)
.git.pre_commit.hook_ids array Flattened, deduplicated list of all configured hook IDs
.git.pre_commit.hook_count number Total number of hooks across all repos
.git.pre_commit.repo_count number Total number of repos[] entries
.git.pre_commit.ci_skip array Top-level ci.skip list — hook IDs disabled in pre-commit.ci
.git.pre_commit.all_pinned boolean true when every repo has a rev pinned to a non-floating ref
.git.attributes.valid boolean Whether the .gitattributes file parsed without errors
.git.attributes.path string Path to the .gitattributes file
.git.attributes.rules_count number Total number of non-comment, non-empty rules
.git.attributes.lfs_patterns array Patterns assigned filter=lfs
.git.attributes.binary_patterns array Patterns assigned the binary macro
.git.attributes.eol_normalized boolean true when at least one rule sets text=auto or equivalent
.git.attributes.export_ignore_patterns array Patterns assigned export-ignore
.git.submodules.valid boolean Whether .gitmodules parsed cleanly
.git.submodules.path string Path to the .gitmodules file
.git.submodules.modules[] array Per-submodule data (name, path, url, branch)

Collectors

Collector Description
pre-commit Parses .pre-commit-config.yaml (or .yml) — first match wins
gitattributes Parses .gitattributes and classifies rules by attribute
gitmodules Parses .gitmodules and extracts each submodule's name/path/url/branch

Installation

Add to your lunar-config.yml:

collectors:
  - uses: github://earthly/lunar-lib/collectors/git@v1.0.0
    on: ["domain:your-domain"]
    # include: [pre-commit, gitattributes]  # Run a subset
    # with:
    #   pre_commit_paths: ".pre-commit-config.yaml,.pre-commit-config.yml"
    #   gitattributes_paths: ".gitattributes"

Open Source

This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

Ready to Automate Your Standards?

See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 200+ built-in guardrails.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo