From 30dbe08e2e448cb8c26838b47c266556d5d3db0b Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Tue, 10 Dec 2019 18:00:07 -0800 Subject: [PATCH 1/4] Introduce Xgit.Repository module. This will be the container for the "porcelain" commands once they are implemented. --- lib/xgit/repository.ex | 29 +++++++++++++++++++++++++++ test/xgit/repository/on_disk_test.exs | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 lib/xgit/repository.ex diff --git a/lib/xgit/repository.ex b/lib/xgit/repository.ex new file mode 100644 index 0000000..49f542e --- /dev/null +++ b/lib/xgit/repository.ex @@ -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 diff --git a/test/xgit/repository/on_disk_test.exs b/test/xgit/repository/on_disk_test.exs index 0330290..a7cf30b 100644 --- a/test/xgit/repository/on_disk_test.exs +++ b/test/xgit/repository/on_disk_test.exs @@ -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 @@ -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) From 52b2632d6ec6a0c271a662e58114e22dc2c34685 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Fri, 13 Dec 2019 21:20:49 -0800 Subject: [PATCH 2/4] Remove reference to the no-longer-planned `api` folder. --- lib/xgit/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/xgit/README.md b/lib/xgit/README.md index 4fe6196..96b40c4 100644 --- a/lib/xgit/README.md +++ b/lib/xgit/README.md @@ -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. From 4065b83acda15f4dae99d5184d27e69a3da6d592 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Fri, 13 Dec 2019 21:37:12 -0800 Subject: [PATCH 3/4] Organize ExDoc content. --- mix.exs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d5cdc11..d3a4334 100644 --- a/mix.exs +++ b/mix.exs @@ -52,7 +52,37 @@ 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 From 6bdd555281342505086c2c4a17f37811444813b0 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Fri, 13 Dec 2019 21:40:06 -0800 Subject: [PATCH 4/4] Fix code format. --- mix.exs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index d3a4334..ad18226 100644 --- a/mix.exs +++ b/mix.exs @@ -54,7 +54,7 @@ defmodule Xgit.MixProject do source_url: "https://github.com/elixir-git/xgit", homepage_url: "https://xgit.io", groups_for_modules: [ - "Repository": [ + Repository: [ "Xgit.Repository", "Xgit.Repository.InMemory", "Xgit.Repository.OnDisk", @@ -79,10 +79,8 @@ defmodule Xgit.MixProject do "Xgit.Repository.WorkingTree", "Xgit.Repository.WorkingTree.ParseIndexFile", "Xgit.Repository.WorkingTree.WriteIndexFile" - ] ] - ] end