Ragex.Git.Repo (Ragex v0.17.3)

View Source

Repository detection and metadata.

Discovers the git repository root for a given working directory and caches the result. All git operations in Ragex start by calling Repo.root/1 to establish the repo context.

Examples

iex> Ragex.Git.Repo.root("/opt/my_project/lib")
{:ok, "/opt/my_project"}

iex> Ragex.Git.Repo.git_available?()
true

Summary

Functions

Returns the current branch name for the repo containing path.

Returns true if the git binary is available on the system.

Returns true if the given path is inside a git repository.

Returns a project hash suitable for cache file paths.

Returns the repository root for a working directory.

Functions

current_branch(path)

@spec current_branch(String.t()) :: {:ok, String.t()} | {:error, term()}

Returns the current branch name for the repo containing path.

git_available?()

@spec git_available?() :: boolean()

Returns true if the git binary is available on the system.

in_repo?(path)

@spec in_repo?(String.t()) :: boolean()

Returns true if the given path is inside a git repository.

project_hash(repo_root)

@spec project_hash(String.t()) :: String.t()

Returns a project hash suitable for cache file paths.

Uses the repo root path to generate a deterministic short hash.

root(work_dir)

@spec root(String.t()) :: {:ok, String.t()} | {:error, term()}

Returns the repository root for a working directory.

Caches the result in the process dictionary to avoid repeated git calls within the same process (e.g. during a single MCP tool invocation).