View Source Gitly (gitly v0.1.0)
A module for downloading and extracting Git repositories.
This module provides functionality to download repositories from various Git hosting services, extract them, and manage the process with various options for caching, retrying, and formatting.
Summary
Functions
Downloads a repository and returns the path to the archive.
Extracts an archive to a given destination.
Extracts an archive to a specified destination.
Downloads a repository and returns the path to the extracted archive.
Types
@type opts() :: [ force: boolean(), cache: boolean(), overwrite: boolean(), retry: :safe_transient | :transient | retry_fun() | false, retry_delay: retry_delay_fun(), retry_log_level: atom() | false, max_retries: non_neg_integer(), ref: String.t(), root: Path.t(), format: :zip | :tar | :tar_gz | :tgz ]
@type retry_delay_fun() :: (non_neg_integer() -> non_neg_integer())
@type retry_fun() :: (Req.Request.t(), Req.Response.t() | Exception.t() -> boolean() | {:delay, non_neg_integer()} | nil)
Functions
Downloads a repository and returns the path to the archive.
Parameters
repository
- The repository identifier (e.g., "username/repo").opts
- A keyword list of options (see "Options" section ingitly/2
).
Returns
{:ok, path}
wherepath
is the location of the downloaded archive.{:error, reason}
if the download fails.
Examples
iex> Gitly.download("iwatakeshi/gitly")
{:ok, "/path/to/downloaded/archive.zip"}
Extracts an archive to a given destination.
Parameters
path
- The path to the archive file.opts
- A keyword list of options (see "Options" section ingitly/2
).
Returns
{:ok, path}
wherepath
is the location of the extracted contents.{:error, reason}
if the extraction fails.
Examples
iex> Gitly.extract("/path/to/archive.zip")
{:ok, "/path/to/extracted/contents"}
Extracts an archive to a specified destination.
Parameters
path
- The path to the archive file.dest
- The destination path for extraction.opts
- A keyword list of options (see "Options" section ingitly/2
).
Returns
{:ok, path}
wherepath
is the location of the extracted contents.{:error, reason}
if the extraction fails.
Examples
iex> Gitly.extract("/path/to/archive.zip", "/path/to/destination")
{:ok, "/path/to/destination"}
Downloads a repository and returns the path to the extracted archive.
Parameters
repository
- The repository identifier (e.g., "username/repo").opts
- A keyword list of options (see "Options" section).
Options
:force
- If true, force the download of the archive.:cache
- If true, use the local cache to download the archive.:overwrite
- If true, overwrite existing files when extracting the archive.:retry
- Retry options for Req. See https://hexdocs.pm/req/Req.Steps.html#retry/1-request-options:retry_delay
- Function to determine delay between retries. Default is exponential backoff.:retry_log_level
- The log level for retry logs. Set to false to disable logging.:max_retries
- The maximum number of retries before giving up.:ref
- The ref to download from the repository.:root
- The root path to store the archive.:format
- The format of the archive (:zip, :tar, :tar_gz, or :tgz).
Returns
{:ok, path}
wherepath
is the location of the extracted repository.{:error, reason}
if the operation fails.
Examples
iex> Gitly.gitly("iwatakeshi/gitly")
{:ok, "/path/to/extracted/repo"}