danger-packwerk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3338a7622d64fc169f9ef273873bc11002ff56ba3d66b225189f0dc1bd6b6cf9
4
- data.tar.gz: 58cb63b3956cf29245575e8be453280c33041b3ce15579c2102d07819c836c26
3
+ metadata.gz: '0118c3bc15c4a681dc290f557549e24451cd5c3fda714c8a29637ad791f77cfb'
4
+ data.tar.gz: 716b2b0a13d4392cf8263abadca2620e241527c4874e25c93e9ad2b7baec57ee
5
5
  SHA512:
6
- metadata.gz: 31aab3fcdb5c3bb7837214ac46fae8807fcfa9727d9a3d21a4d371c8c8de4db688c13ff486e7e9660ec552f7aa39cbd1c622338e8b88ae087f226362804e8097
7
- data.tar.gz: fba5ddd5b2d9ed86b3173b1aca8562ba523dcd74c974d45570edc07853ac5c4819bf3c64956ca10a037b800db056853cb38097ce422fa79eb2983ab297ea9890
6
+ metadata.gz: ac00cad5d9241aec516693df310a0b97afd8da2bc59f0234d005ab9bc9ae1d3d781fa6c591f9267f03919327ef6f57dc16e2ef6d494d98d8e43acd205c9ef530
7
+ data.tar.gz: 7043ca6402ac04d799dabe1ed8ddce3d4d239ebc6f818236e47b494faa9a5b3b52df1b6148e9a2d35e50788264c6735e70548a814ff12219cb080f2efbf953be
@@ -78,16 +78,21 @@ module DangerPackwerk
78
78
  removed_violations += deleted_violations
79
79
  end
80
80
 
81
+ # The format for git.renamed_files is a T::Array[{after: "some/path/new", before: "some/path/old"}]
82
+ renamed_files_before = git.renamed_files.map { |before_after_file| before_after_file[:before] }
83
+ renamed_files_after = git.renamed_files.map { |before_after_file| before_after_file[:after] }
84
+
81
85
  git.modified_files.grep(DEPRECATED_REFERENCES_PATTERN).each do |modified_deprecated_references_yml_file|
86
+ # We skip over modified files if one of the modified files is a renamed `deprecated_references.yml` file.
87
+ # This allows us to rename packs while ignoring "new violations" in those renamed packs.
88
+ next if renamed_files_before.include?(modified_deprecated_references_yml_file)
89
+
82
90
  head_commit_violations = BasicReferenceOffense.from(modified_deprecated_references_yml_file)
83
91
  base_commit_violations = get_violations_before_patch_for(modified_deprecated_references_yml_file)
84
92
  added_violations += head_commit_violations - base_commit_violations
85
93
  removed_violations += base_commit_violations - head_commit_violations
86
94
  end
87
95
 
88
- # The format for git.renamed_files is a T::Array[{after: "some/path/new", before: "some/path/old"}]
89
- renamed_files = git.renamed_files.map { |before_after_file| before_after_file[:after] }
90
-
91
96
  #
92
97
  # This implementation creates some false negatives:
93
98
  # That is – it doesn't capture some cases:
@@ -106,11 +111,11 @@ module DangerPackwerk
106
111
 
107
112
  added_violations.each do |violation|
108
113
  filepath_that_defines_this_constant = Private.constant_resolver.resolve(violation.class_name)&.location
109
- renamed_constants << violation.class_name if renamed_files.include?(filepath_that_defines_this_constant)
114
+ renamed_constants << violation.class_name if renamed_files_after.include?(filepath_that_defines_this_constant)
110
115
  end
111
116
 
112
117
  relevant_added_violations = added_violations.reject do |violation|
113
- renamed_files.include?(violation.file) || renamed_constants.include?(violation.class_name)
118
+ renamed_files_after.include?(violation.file) || renamed_constants.include?(violation.class_name)
114
119
  end
115
120
 
116
121
  ViolationDiff.new(
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module DangerPackwerk
5
- VERSION = '0.6.0'
5
+ VERSION = '0.7.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-packwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2022-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api