ExGitEngine

Elixir libgit2 wrapper with GenServer-based concurrent access and Git wire protocol (push/fetch).

Originally created by Mario Flach (@redrabbit) as part of git.limo. Extracted and updated by @jtippett. Extended with Git wire protocol support and maintained by Sergey Moiseev.

Requirements

libgit2 must be installed on your system:

brew install libgit2 # macOS
sudo apt-get install libgit2-dev # Ubuntu/Linux

Installation

{:ex_git_engine, "~> 0.9"}

Architecture

Three abstraction layers:

Wire protocol:

Usage

{:ok, agent} = ExGitEngine.GitAgent.start_link("/path/to/repo")
{:ok, ref} = ExGitEngine.GitAgent.reference_lookup(agent, "refs/heads/main")
{:ok, commit} = ExGitEngine.GitAgent.peel(agent, ref)
{:ok, message} = ExGitEngine.GitAgent.commit_message(agent, commit)

Implement ExGitEngine.GitRepo to add custom push validation or post-push hooks:

defimpl ExGitEngine.GitRepo, for: MyRepo do
def get_agent(repo), do: {:ok, repo.agent_pid}
def pre_push(repo, cmds), do: :ok
def push(repo, cmds), do: {:ok, repo}
end

License

MIT