Ragex.Git.RepoServer (Ragex v0.15.0)

View Source

GenServer that owns the egit NIF repository reference.

NIF resources are process-bound in the BEAM: the repo handle opened by :git.open/1 is only valid in the process that created it. This GenServer holds that handle and serializes all NIF calls through it.

If libgit2 segfaults (unlikely but possible with a beta NIF), only this process dies. The supervisor restarts it and re-opens the repo.

Started only when egit is available. When the :git module is not loaded, this GenServer is not added to the supervision tree.

Summary

Functions

Execute an egit function against the held repo reference.

Returns a specification to start this module under a supervisor.

Returns the currently opened repo path, or nil.

Open (or re-open) a repository at the given path.

Functions

call(function, args)

@spec call(atom(), [term()]) :: term()

Execute an egit function against the held repo reference.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

current_path()

@spec current_path() :: String.t() | nil

Returns the currently opened repo path, or nil.

open(repo_path)

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

Open (or re-open) a repository at the given path.

start_link(opts \\ [])