Workspace.Git (Workspace v0.2.1)
View SourceHelper git related functions
Summary
Functions
Detects the changed files in the given directory.
Get changed files between the given head
and base
git references.
Get the git repo root of the given path
Returns a list of uncommitted files
Get list of untracked files
Types
Functions
@spec changed(opts :: keyword()) :: {:ok, [{binary(), change_type()}]} | {:error, binary()}
Detects the changed files in the given directory.
By default the following files are included:
- Uncommitted files in the working directory
- Untracked files in the working directory
- If
:base
is provided it also includes:- The changed files between
:base
andHEAD
if no:head
is set. - The changed files between
:base
and:head
if:head
is set.
- The changed files between
A list of tuples of the form {"path/to/changed/file", change_type}
is
returned, where change_type
can be one of the following:
:uncommitted
- for changed files under version control that are not committed:untracked
- for new files that are not under version control:modified
- for changed committed files between theHEAD
and theBASE
Options
:cd
(binary/0
) - The git repo path, defaults to the current working directory.:base
(binary/0
) - The base reference to use for comparing to theHEAD
, can be a branch, a commit or any othergit
reference.:head
(binary/0
) - Thehead
to use for comparing to:base
, if not set defaults toHEAD
. Can be any git reference
@spec changed_files(head :: binary(), base :: binary(), opts :: keyword()) :: {:ok, [binary()]} | {:error, binary()}
Get changed files between the given head
and base
git references.
Options
:cd
(binary/0
) - The git repo path, defaults to the current working directory.
Get the git repo root of the given path
Returns {:ok, path}
in case of success or {:error, reason}
in
case of failure.
Options
:cd
- the path to use for getting the git root, if not set defaults to the current working directory.
Returns a list of uncommitted files
Uncommitted are considered the files that are staged but not committed yet.
Options
:cd
(binary/0
) - The git repo path, defaults to the current working directory.
Get list of untracked files
Options
:cd
(binary/0
) - The git repo path, defaults to the current working directory.