Module: NdrDevSupport::RakeCI::CommitCop
- Defined in:
- lib/ndr_dev_support/rake_ci/commit_cop.rb,
lib/ndr_dev_support/rake_ci/commit_cop/renamed_migration.rb,
lib/ndr_dev_support/rake_ci/commit_cop/modified_migration.rb,
lib/ndr_dev_support/rake_ci/commit_cop/concerns/deputisable.rb,
lib/ndr_dev_support/rake_ci/commit_cop/missing_associated_test_file.rb,
lib/ndr_dev_support/rake_ci/commit_cop/migration_without_structure_dump.rb
Overview
This module encapsulates commit cop logic
Defined Under Namespace
Modules: Deputisable Classes: MigrationWithoutStructureDump, MissingAssociatedTestFile, ModifiedMigration, RenamedMigration
Constant Summary collapse
- COMMIT_COPS =
[ MigrationWithoutStructureDump, MissingAssociatedTestFile, ModifiedMigration, RenamedMigration ].freeze
Class Method Summary collapse
-
.changes(commit) ⇒ Object
converts the deltas into a simpler changes hash of filename sets representation.
-
.each_delta(commit, &block) ⇒ Object
enumerates over each delta of the commmit.
-
.with_pattern ⇒ Object
Isolates migration/structure pattern changes by resetting them after yielding.
Class Method Details
.changes(commit) ⇒ Object
converts the deltas into a simpler changes hash of filename sets representation
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 |
.each_delta(commit, &block) ⇒ Object
enumerates over each delta of the commmit
45 46 47 48 49 |
# 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 |
.with_pattern ⇒ Object
Isolates migration/structure pattern changes by resetting them after yielding
68 69 70 71 72 73 74 75 76 |
# 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 |