Minga.Project.FileTree.GitStatus (Minga v0.1.0)

Copy Markdown View Source

Computes git status for all files under a directory tree.

Runs git status --porcelain=v1 and parses the output into a map of %{absolute_path => status_atom}. Also propagates status up to parent directories so collapsed dirs show the "worst" child status.

This module is pure (no GenServer). The caller is responsible for caching the result and refreshing it on save/git operations.

Summary

Types

Git status for a single file.

Status map keyed by absolute file path.

Functions

Computes git status for all files under root_path.

Returns the severity rank for a status (higher = more urgent). Used for directory propagation: the "worst" child status wins.

Returns the display symbol for a git status.

Types

file_status()

@type file_status() ::
  :staged | :modified | :untracked | :conflict | :renamed | :deleted

Git status for a single file.

status_map()

@type status_map() :: %{required(String.t()) => file_status()}

Status map keyed by absolute file path.

Functions

compute(root_path)

@spec compute(String.t()) :: status_map()

Computes git status for all files under root_path.

Returns a status map with absolute paths as keys. If the path is not inside a git repo, returns an empty map. Directory entries are included with the "worst" status of any descendant.

Runs asynchronously-friendly: no side effects, no process state.

severity(atom)

@spec severity(file_status()) :: non_neg_integer()

Returns the severity rank for a status (higher = more urgent). Used for directory propagation: the "worst" child status wins.

symbol(atom)

@spec symbol(file_status()) :: String.t()

Returns the display symbol for a git status.