Class: Dependabot::Gradle::FileUpdater::Wrapper::PropertiesReconciler
- Inherits:
-
Object
- Object
- Dependabot::Gradle::FileUpdater::Wrapper::PropertiesReconciler
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/gradle/file_updater/wrapper/properties_reconciler.rb
Overview
Reconciles the gradle-wrapper.properties file after Gradle's wrapper task has
regenerated it from hardcoded defaults (see https://github.com/gradle/gradle/issues/36172).
The reconciliation policy is deliberately conservative: the user's original file is the source of truth for everything (comments, ordering, custom keys, networkTimeout, retries, retryBackOffMs, validateDistributionUrl, distributionBase/Path, store paths, ...). Only the keys that legitimately change for a version bump are taken from the regenerated file.
Constant Summary collapse
- MANAGED_KEYS =
Keys whose value is owned by the update itself and therefore taken from the regenerated file. Everything not listed here is preserved verbatim from the user's original file.
%w(distributionUrl distributionSha256Sum).freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(original_content:, regenerated_content:) ⇒ PropertiesReconciler
constructor
A new instance of PropertiesReconciler.
- #reconcile ⇒ Object
Constructor Details
#initialize(original_content:, regenerated_content:) ⇒ PropertiesReconciler
Returns a new instance of PropertiesReconciler.
41 42 43 44 |
# File 'lib/dependabot/gradle/file_updater/wrapper/properties_reconciler.rb', line 41 def initialize(original_content:, regenerated_content:) @original_content = original_content @regenerated_content = regenerated_content end |
Class Method Details
.reconcile(original_content:, regenerated_content:) ⇒ Object
36 37 38 |
# File 'lib/dependabot/gradle/file_updater/wrapper/properties_reconciler.rb', line 36 def self.reconcile(original_content:, regenerated_content:) new(original_content: original_content, regenerated_content: regenerated_content).reconcile end |
Instance Method Details
#reconcile ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dependabot/gradle/file_updater/wrapper/properties_reconciler.rb', line 47 def reconcile original_content = @original_content regenerated_content = @regenerated_content return original_content if original_content.nil? || regenerated_content.nil? document = PropertiesDocument.parse(original_content) regenerated = PropertiesDocument.parse(regenerated_content) MANAGED_KEYS.each do |key| new_value = regenerated.value_for(key) next if new_value.nil? document.upsert(key, new_value) end document.to_s end |