Represents the parsed result of a git commit command.
Contains the branch name, short commit hash, commit subject, and change statistics (files changed, insertions, deletions).
hash is the abbreviated hash git prints; full_hash is the full 40-char
SHA, resolved by Git.commit/2 so callers get a stable identifier without a
follow-up rev-parse. full_hash is the empty string only if that
resolution could not run (for example a bare Git.CommitResult.parse/1).
Summary
Functions
Parses the output of git commit into a Git.CommitResult struct.
Types
@type t() :: %Git.CommitResult{ branch: String.t(), deletions: non_neg_integer(), files_changed: non_neg_integer(), full_hash: String.t(), hash: String.t(), insertions: non_neg_integer(), subject: String.t() }
Functions
Parses the output of git commit into a Git.CommitResult struct.
The expected format is:
[branch hash] subject
N file(s) changed, N insertion(s)(+), N deletion(s)(-)Also handles root commits:
[branch (root-commit) hash] subjectExamples
iex> output = "[main abc1234] the commit message\n 1 file changed, 5 insertions(+), 2 deletions(-)\n"
iex> result = Git.CommitResult.parse(output)
iex> result.branch
"main"
iex> result.hash
"abc1234"
iex> result.subject
"the commit message"