Git.Commands.Bisect (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git bisect.

Supports starting, marking good/bad commits, skipping, resetting, viewing the bisect log, and replaying a bisect session.

Unsupported subcommands

  • visualize - requires a GUI (gitk) and is not suitable for CLI wrapping.
  • run - requires script execution which adds complexity beyond simple command wrapping. May be added in a future release.

Summary

Functions

Returns the argument list for git bisect.

Parses the output of git bisect.

Types

t()

@type t() :: %Git.Commands.Bisect{
  bad: String.t() | nil | :head,
  good: String.t() | nil | :head,
  log: boolean(),
  new_ref: String.t() | nil,
  old_ref: String.t() | nil,
  replay: String.t() | nil,
  reset: boolean(),
  skip: String.t() | nil | :head,
  start: boolean()
}

Functions

args(bisect)

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

Returns the argument list for git bisect.

Builds the subcommand and optional ref argument based on the struct fields.

Examples

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{start: true})
["bisect", "start"]

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{bad: :head})
["bisect", "bad"]

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{bad: "abc1234"})
["bisect", "bad", "abc1234"]

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{good: :head})
["bisect", "good"]

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{reset: true})
["bisect", "reset"]

iex> Git.Commands.Bisect.args(%Git.Commands.Bisect{log: true})
["bisect", "log"]

parse_output(stdout, exit_code)

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

Parses the output of git bisect.

Returns {:ok, %Git.BisectResult{}} on success. The status field indicates the current state of the bisect session. On failure, returns {:error, {stdout, exit_code}}.