Implements the Git.Command behaviour for git check-ref-format.
Validates (and optionally normalizes) a ref name. This command uses its exit
code as data: 0 means the ref is well-formed, a non-zero code means it is
not. That signal is translated into {:ok, _} / {:error, :invalid_ref}
rather than a generic error.
Modes
:normalizenormalizes the ref and prints it on success:branchvalidates a branch-name shorthand and prints its expansion:allow_onelevelaccepts single-level refs (e.g.HEAD)
Summary
Functions
Returns the argument list for git check-ref-format.
Parses the output of git check-ref-format.
Types
Functions
Returns the argument list for git check-ref-format.
Examples
iex> Git.Commands.CheckRefFormat.args(%Git.Commands.CheckRefFormat{ref: "refs/heads/main"})
["check-ref-format", "refs/heads/main"]
iex> Git.Commands.CheckRefFormat.args(%Git.Commands.CheckRefFormat{ref: "refs/heads//main", normalize: true})
["check-ref-format", "--normalize", "refs/heads//main"]
iex> Git.Commands.CheckRefFormat.args(%Git.Commands.CheckRefFormat{ref: "main", branch: true})
["check-ref-format", "--branch", "main"]
iex> Git.Commands.CheckRefFormat.args(%Git.Commands.CheckRefFormat{ref: "HEAD", allow_onelevel: true})
["check-ref-format", "--allow-onelevel", "HEAD"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, true | String.t()} | {:error, :invalid_ref | {String.t(), non_neg_integer()}}
Parses the output of git check-ref-format.
- Exit
0with output (normalize/branch modes) returns{:ok, normalized}. - Exit
0with no output returns{:ok, true}. - Exit
1(and the--branchinvalid-name die at exit128) returns{:error, :invalid_ref}. - Any other non-zero exit (e.g. a usage error) returns
{:error, {stdout, exit_code}}.