Git.Commands.Status (git v0.6.1)

Copy Markdown View Source

Implements the Git.Command behaviour for git status.

Uses --porcelain=v1 -b for machine-readable output with branch information. The porcelain v1 format and the -b flag are always present so the parser in Git.Status keeps working.

Summary

Functions

Returns the argument list for git status.

Parses the output of git status --porcelain=v1 -b.

Types

t()

@type t() :: %Git.Commands.Status{
  ignore_submodules: String.t() | nil,
  ignored: boolean(),
  no_renames: boolean(),
  pathspec: [String.t()],
  renames: boolean(),
  untracked_files: untracked_files() | nil
}

untracked_files()

@type untracked_files() :: :no | :normal | :all

Functions

args(command)

@spec args(t()) :: [String.t()]

Returns the argument list for git status.

The base is always ["status", "--porcelain=v1", "-b"]. Additional flags are appended based on the struct fields, and any :pathspec entries are added last after a -- separator.

parse_output(stdout, exit_code)

@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, Git.Status.t()} | {:error, {String.t(), non_neg_integer()}}

Parses the output of git status --porcelain=v1 -b.

On success (exit code 0), returns {:ok, %Git.Status{}}. On failure, returns {:error, {stdout, exit_code}}.