File tree Expand file tree Collapse file tree
lib/octocatalog-diff/catalog-diff Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,10 +191,8 @@ def catdiff
191191
192192 # Legacy options which are now filters
193193 @opts [ :filters ] ||= [ ]
194- if @opts [ :suppress_absent_file_details ] && !@opts [ :filters ] . include? ( 'AbsentFile' )
195- @opts [ :filters ] << 'AbsentFile'
196- end
197- @opts [ :filters ] << 'CompilationDir' unless @opts [ :filters ] . include? ( 'CompilationDir' )
194+ add_element_to_array ( @opts [ :filters ] , 'CompilationDir' )
195+ add_element_to_array ( @opts [ :filters ] , 'AbsentFile' ) if @opts [ :suppress_absent_file_details ]
198196
199197 # Apply any additional pluggable filters.
200198 filter_opts = {
@@ -209,6 +207,13 @@ def catdiff
209207 result
210208 end
211209
210+ # Add an element to an array if it doesn't already exist in that array
211+ # @param array_in [Array] Array to have element added (**mutated** by this method)
212+ # @param element [?] Element to add
213+ def add_element_to_array ( array_in , element )
214+ array_in << element unless array_in . include? ( element )
215+ end
216+
212217 # Filter the differences for any items that were ignored, by some combination of type, title, and
213218 # attribute. This modifies the array itself by selecting only items that do not meet the ignored
214219 # filter.
You can’t perform that action at this time.
0 commit comments