Implements the Git.Command behaviour for git clone.
Supports cloning a repository with optional --depth (shallow clone) and
--branch flags. An optional target directory name may also be specified.
Summary
Types
@type t() :: %Git.Commands.Clone{ branch: String.t() | nil, depth: pos_integer() | nil, directory: String.t() | nil, url: String.t() }
Functions
Returns the argument list for git clone.
Always includes the repository URL. Optional flags are appended in order:
--depth=N, --branch=NAME, and a target directory when set.
Examples
iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git"})
["clone", "https://example.com/repo.git"]
iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", depth: 1})
["clone", "--depth=1", "https://example.com/repo.git"]
iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", branch: "main", depth: 1})
["clone", "--depth=1", "--branch=main", "https://example.com/repo.git"]
iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", directory: "my-repo"})
["clone", "https://example.com/repo.git", "my-repo"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git clone.
On success (exit code 0), returns {:ok, :done}.
On failure, returns {:error, {stdout, exit_code}}.