Hamburger Cross Icon
Submodules No Floating Branches
+
Git Collector

Submodules No Floating Branches + Git Collector

✓ Guardrail ↓ Collector Beta Devex Build And Ci

Enforce Submodules No Floating Branches using data collected by Git Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Flags submodules that declare a `branch` field in `.gitmodules`, since that signals the submodule is intended to track a floating ref via `git submodule update --remote` (defeating the always-pinned-by-SHA default). Skips when no `.gitmodules` is present — submodule-free repos are not penalized.
Data Source: 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).

How Git Collector Powers This Guardrail

The Git Collector gathers metadata from your code analysis systems. This data flows into Lunar's Component JSON, where the Submodules No Floating Branches guardrail evaluates it against your standards.

When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.

1
↓ Git Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
✓ Submodules No Floating Branches Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# Step 1: Enable the Git Collector
collectors:
  - uses: github://earthly/lunar-lib/collectors/git@v1.0.5
    # with: ...

# Step 2: Enable the Git Guardrails
policies:
  - uses: github://earthly/lunar-lib/policies/git@v1.0.5
    include: [submodules-no-floating-branches]
    # with: ...

What Git Collector Collects

This collector gathers the following data that the Submodules No Floating Branches guardrail evaluates.

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.

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.

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.

Example Data Flow

Here's an example of the data that Git Collector writes to the Component JSON, which Submodules No Floating Branches then evaluates.

{ } component.json From Git Collector
{
  "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 Options

Git Collector 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)

Git Guardrails Inputs

Input Required Default Description
secret_scan_hook_ids Optional gitleaks,detect-secrets,trufflehog,detect-aws-credentials,detect-private-key Comma-separated list of pre-commit hook IDs that count as secret scanners

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 300+ 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
Auto-ID My Guardrails
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo