global
def analyze_patchset(patchset, depth = 0)
Diff::LCS::Change objects to the object form of same) and detection of
single-pass normalization (conversion of the array form of
This method will analyze the provided patchset to provide a
def analyze_patchset(patchset, depth = 0) raise "Patchset too complex" if depth > 1 has_changes = false # Format: # [ # patchset # # hunk (change) # [ # hunk # # change # ] # ] patchset = patchset.map do |hunk| case hunk when Diff::LCS::Change has_changes ||= !hunk.unchanged? hunk when Array # Detect if the 'hunk' is actually an array-format # Change object. if Diff::LCS::Change.valid_action? hunk[0] hunk = Diff::LCS::Change.from_a(hunk) has_changes ||= !hunk.unchanged? hunk else with_changes, hunk = analyze_patchset(hunk, depth + 1) has_changes ||= with_changes hunk.flatten end else raise ArgumentError, "Cannot normalise a hunk of class #{hunk.class}." end end [ has_changes, patchset.flatten(1) ] end