class Agate::Patch

Overview

A patch represents the changes for a single delta (file) in a diff.

Included Modules

Defined in:

agate/patch.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_diff(diff : Diff, index : Int32) : Patch #

Creates a patch from a diff at the given delta index.


[View source]
def self.from_strings(old_content : String | Nil = nil, new_content : String | Nil = nil, old_path : String | Nil = nil, new_path : String | Nil = nil) : Patch #

Creates a patch from two strings (no repo needed).


[View source]

Class Method Detail

def self.from_diff?(diff : Diff, index : Int32) : Patch | Nil #

Creates a patch from a diff at the given delta index, or nil.


[View source]

Instance Method Detail

def delta : Diff::Delta #

Returns the delta associated with this patch.


[View source]
def each(& : Diff::Hunk -> ) : Nil #

Iterates over hunks in this patch.


[View source]
def each_hunk(& : Diff::Hunk -> ) : Nil #

Alias for each.


[View source]
def header : String #

Returns the patch header (without hunk content).


[View source]
def hunk_count : Int32 #

Returns the number of hunks in this patch.


[View source]
def hunks : Array(Diff::Hunk) #

Returns all hunks as an array.


[View source]
def stat : NamedTuple(context: Int32, additions: Int32, deletions: Int32) #

Returns statistics as {context, additions, deletions}.


[View source]
def to_s(io : IO) : Nil #

Returns the patch as a string.


[View source]