Git.Conflicts (git v0.4.0)

Copy Markdown View Source

Merge conflict detection and resolution helpers that compose Git.status/1 and Git.merge/2.

All functions accept an optional keyword list. Use :config to specify the repository via a Git.Config struct; when omitted a default config is built from the environment.

Summary

Functions

Aborts an in-progress conflicted merge.

Checks whether the repository is in a conflicted state.

Lists file paths that have merge conflicts.

Checks whether all conflicts have been resolved.

Functions

abort_merge(opts \\ [])

@spec abort_merge(keyword()) :: {:ok, :done} | {:error, term()}

Aborts an in-progress conflicted merge.

Delegates to Git.merge(:abort).

Options

Examples

{:ok, :done} = Git.Conflicts.abort_merge()

detect(opts \\ [])

@spec detect(keyword()) :: {:ok, boolean()} | {:error, term()}

Checks whether the repository is in a conflicted state.

Uses Git.status/1 and inspects entries for unmerged status codes.

Returns {:ok, true} when conflicts exist, {:ok, false} otherwise.

Options

Examples

{:ok, false} = Git.Conflicts.detect()

files(opts \\ [])

@spec files(keyword()) :: {:ok, [String.t()]} | {:error, term()}

Lists file paths that have merge conflicts.

Uses Git.status/1 and filters for entries with unmerged status codes.

Returns {:ok, [String.t()]}.

Options

Examples

{:ok, files} = Git.Conflicts.files()

resolved?(opts \\ [])

@spec resolved?(keyword()) :: {:ok, boolean()} | {:error, term()}

Checks whether all conflicts have been resolved.

This is the inverse of detect/1 -- returns {:ok, true} when no unmerged files exist.

Options

Examples

{:ok, true} = Git.Conflicts.resolved?()