Xgit v0.1.0 Xgit.Repository.OnDisk

Implementation of Xgit.Repository that stores content on the local file system.

IMPORTANT NOTE: This is intended as a reference implementation largely for testing purposes and may not necessarily handle all of the edge cases that the traditional git command-line interface will handle.

That said, it does intentionally use the same .git folder format as command-line git so that results may be compared for similar operations.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Creates a new, empty git repository on the local file system.

Start an on-disk git repository.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

create(work_dir)
create(work_dir :: String.t()) :: :ok | {:error, reason :: String.t()}

Creates a new, empty git repository on the local file system.

Analogous to git init.

NOTE: We use the name create here so as to avoid a naming conflict with GenServer.init/1.

Parameters

work_dir (String) is the top-level working directory. A .git directory is created inside this directory.

Return Value

:ok if created successfully.

{:error, "reason"} if not.

Link to this function

start_link(opts \\ [])
start_link(opts :: Keyword.t()) :: GenServer.on_start()

Start an on-disk git repository.

Use the functions in Xgit.Repository to interact with this repository process.

Options

  • :work_dir (required): Top-level working directory. A .git directory should exist at this path. Use create/1 to create an empty on-disk repository if necessary.

Any other options are passed through to GenServer.start_link/3.

Return Value

See GenServer.start_link/3.