ExAthena.GitDiff (ExAthena v0.17.0)

Copy Markdown View Source

Single source of truth for the "all working-tree changes vs HEAD" diff that the chat UIs render (web Git tab + TUI Changes tab).

git diff HEAD alone shows modified and deleted tracked files but NOT untracked (newly created) files. To make every change reviewable, this module appends a synthetic new file diff for each untracked, non-ignored file — capped so a generated/binary blob can't flood the pane.

External git invocations are wrapped in Task.async/yield with a timeout (System.cmd has none) so a hung repo can never wedge the caller.

Summary

Functions

Build the combined unified diff (tracked changes vs HEAD + synthetic untracked files) for cwd.

Types

error()

@type error() :: :not_a_repo | :no_git | :timeout

Functions

build(cwd)

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

Build the combined unified diff (tracked changes vs HEAD + synthetic untracked files) for cwd.

Returns {:ok, ""} when there are no changes, {:ok, diff_text} otherwise, or {:error, reason} for a non-repo / missing-git / git-failure.