Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Introduce new Xgit.Repository module. #256

Merged
merged 4 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/xgit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Code in Xgit is organized into the following categories, reflected in module nam
and corresponding folder organization, listed here roughly in order from top to bottom
of the dependency sequence:

* **`api`** _(none implemented yet)_: These are the typical commands or operations
that you perform on a git repository. In the git vernacular, these are often
referred to as **porcelain** (i.e. the refined, user-visible operations).

* **`repository`**: This describes how a single git repository is persisted. A
reference "on-disk" implementation is provided and is designed to interoperate
with the existing git command-line tool.
Expand Down
29 changes: 29 additions & 0 deletions lib/xgit/repository.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule Xgit.Repository do
@moduledoc ~S"""
Represents a git repository.

Create a repository by calling the `start_link` function on one of the modules
that implements `Xgit.Repository.Storage`. The resulting PID can be used when
calling functions in this module and `Xgit.Repository.Plumbing`.

The functions implemented in this module correspond to the "plumbing" commands
implemented by command-line git.

(As of this writing, no plumbing-level commands have been implemented yet.)
"""
alias Xgit.Repository.Storage

@typedoc ~S"""
The process ID for an `Xgit.Repository` process.

This is the same process ID returned from the `start_link` function of any
module that implements `Xgit.Repository.Storage`.
"""
@type t :: pid

@doc ~S"""
Returns `true` if the argument is a PID representing a valid `Xgit.Repository` process.
"""
@spec valid?(repository :: term) :: boolean
defdelegate valid?(repository), to: Storage
end
30 changes: 29 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,35 @@ defmodule Xgit.MixProject do
logo: "branding/xgit-logo.png",
canonical: "http://hexdocs.pm/xgit",
source_url: "https://github.com/elixir-git/xgit",
homepage_url: "https://xgit.io"
homepage_url: "https://xgit.io",
groups_for_modules: [
Repository: [
"Xgit.Repository",
"Xgit.Repository.InMemory",
"Xgit.Repository.OnDisk",
"Xgit.Repository.Plumbing",
"Xgit.Repository.Storage"
],
"Core Data Model": [
"Xgit.Core.Commit",
"Xgit.Core.ContentSource",
"Xgit.Core.DirCache",
"Xgit.Core.DirCache.Entry",
"Xgit.Core.FileContentSource",
"Xgit.Core.FileMode",
"Xgit.Core.FilePath",
"Xgit.Core.Object",
"Xgit.Core.ObjectId",
"Xgit.Core.ObjectType",
"Xgit.Core.PersonIdent",
"Xgit.Core.Ref",
"Xgit.Core.Tree",
"Xgit.Core.Tree.Entry",
"Xgit.Repository.WorkingTree",
"Xgit.Repository.WorkingTree.ParseIndexFile",
"Xgit.Repository.WorkingTree.WriteIndexFile"
]
]
]
end

Expand Down
2 changes: 2 additions & 0 deletions test/xgit/repository/on_disk_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Xgit.Repository.OnDiskTest do
use Xgit.GitInitTestCase, async: true

alias Xgit.Repository
alias Xgit.Repository.OnDisk
alias Xgit.Repository.Storage
alias Xgit.Repository.WorkingTree
Expand All @@ -13,6 +14,7 @@ defmodule Xgit.Repository.OnDiskTest do

assert {:ok, repo} = OnDisk.start_link(work_dir: xgit)
assert is_pid(repo)
assert Repository.valid?(repo)
assert Storage.valid?(repo)

assert working_tree = Storage.default_working_tree(repo)
Expand Down