Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:MaterializeInc Materialize Git Utilities

From Leeroopedia


Knowledge Sources
Domains Version Control, Build System, CI/CD
Last Updated 2026-02-08 00:00 GMT

Overview

The Git Utilities module provides Python wrappers around Git CLI operations for revision parsing, tag management, file discovery, and version resolution used across the Materialize build and CI infrastructure.

Description

This module wraps common Git operations into typed Python functions used by the build system, CI pipelines, and development tools. Key functions include rev_count() for counting commits, rev_parse() for resolving revisions to SHA hashes or abbreviated refs, and expand_globs() for finding unignored files respecting .gitignore rules. The expand_globs() function uses a combination of git diff against the empty tree and git ls-files to correctly handle both tracked and untracked files. The module also manages remote tag fetching with deduplication tracking via fetched_tags_in_remotes.

Usage

Use these utilities when programmatically interacting with the Git repository from Python scripts, CI tools, or the build system. They provide type-safe, error-handling wrappers over raw Git CLI invocations.

Code Reference

Source Location

Signature

MATERIALIZE_REMOTE_URL = "https://github.com/MaterializeInc/materialize"

def rev_count(rev: str) -> int: ...
def rev_parse(rev: str, *, abbrev: bool = False) -> str: ...

@functools.cache
def expand_globs(root: Path, *specs: Path | str) -> set[str]: ...

Import

from materialize.git import rev_count, rev_parse, expand_globs

I/O Contract

Input Type Description
rev str Git revision in any format (SHA, tag, branch, HEAD~N)
root Path Repository root for file glob expansion
specs str File path specs to expand
Output Type Description
rev_count int Number of commits from initial commit to specified revision
rev_parse str 40-char hex SHA or abbreviated ref name
expand_globs set[str] Set of unignored file paths matching the specs

Usage Examples

from materialize.git import rev_count, rev_parse, expand_globs
from pathlib import Path

# Get commit count
count = rev_count("HEAD")

# Resolve a tag to its SHA
sha = rev_parse("v0.50.0")

# Get abbreviated ref
branch = rev_parse("HEAD", abbrev=True)

# Find all Python files
files = expand_globs(Path("."), "misc/python/**/*.py")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment