module NdrDevSupport::RakeCI::CommitCop
This module encapsulates commit cop logic
Constants
- COMMIT_COPS
Public Class Methods
Source
# File lib/ndr_dev_support/rake_ci/commit_cop.rb, line 52 def self.changes(commit) changes = { added: Set.new, deleted: Set.new, modified: Set.new, renamed: Set.new } each_delta(commit) do |delta| if delta.status == :renamed changes[delta.status].add([delta.old_file[:path], delta.new_file[:path]]) else # old_file and new_file are the same changes[delta.status].add(delta.old_file[:path]) end end changes end
converts the deltas into a simpler changes hash of filename sets representation
Source
# File lib/ndr_dev_support/rake_ci/commit_cop.rb, line 45 def self.each_delta(commit, &block) diffs = commit.parents.first.diff(commit) diffs.find_similar! diffs.each_delta(&block) end
enumerates over each delta of the commmit
Source
# File lib/ndr_dev_support/rake_ci/commit_cop.rb, line 68 def self.with_pattern default_migration_paths = migration_paths default_structure_dump_pattern = structure_dump_pattern yield self.migration_paths = default_migration_paths self.structure_dump_pattern = default_structure_dump_pattern end
Isolates migration/structure pattern changes by resetting them after yielding