Ragex. Git. Backend behaviour
(Ragex v0.17.1)
View Source
Behaviour defining the contract for git backend implementations.
Two implementations exist:
Ragex.Git.Backend.CLI-- shells out to thegitbinary. Universal fallback that works everywheregitis installed. Also the only path for operations thatlibgit2doesn't support (e.g.git log -Lfor function evolution).Ragex.Git.Backend.Egit-- NIF bindings tolibgit2via theegitpackage. Faster (no process spawn, no text parsing) but requireslibgit2-devat build time and is an optional dependency.
Backend selection is automatic: if :git (egit) is loaded, prefer it; otherwise
fall back to CLI. Override via config :ragex, git_backend: :egit | :cli | :auto.
Summary
Callbacks
Blame a file, returning per-line authorship.
Look up a single commit by SHA.
List files changed between two revisions.
List commits touching a path.
Return the repository root for the given working directory.
List commit SHAs reachable from rev, newest first.
Functions
Returns the active backend module based on configuration and availability.
Returns true when the egit NIF module is compiled and loadable.
Types
Callbacks
@callback blame(path(), path(), keyword()) :: {:ok, [Ragex.Git.BlameEntry.t()]} | {:error, term()}
Blame a file, returning per-line authorship.
Options
:start_line-- first line (1-indexed, default 1):end_line-- last line (default: end of file)
@callback commit_info(path(), sha()) :: {:ok, Ragex.Git.Commit.t()} | {:error, term()}
Look up a single commit by SHA.
List files changed between two revisions.
Returns {:ok, [{path, status}]} where status is :added | :modified | :deleted | :renamed.
@callback log(path(), path(), keyword()) :: {:ok, [Ragex.Git.Commit.t()]} | {:error, term()}
List commits touching a path.
Options
:max_count-- limit results (default 50):since-- ISO-8601 date string or~Ddate:author-- filter by author substring
Return the repository root for the given working directory.
List commit SHAs reachable from rev, newest first.
Options
:max_count-- limit results (default 500)
Functions
@spec active() :: module()
Returns the active backend module based on configuration and availability.
Resolution order:
- Explicit config
:ragex, :git_backend(:egitor:cli) - Auto-detect: egit if loaded, otherwise CLI
@spec egit_available?() :: boolean()
Returns true when the egit NIF module is compiled and loadable.