You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/21 15:22:04 UTC

[sling-whiteboard] branch master updated: [feature-diff] in order to replace an extension, it has to be removed from the prototype and added in the new, they will be merged otherwise

This is an automated email from the ASF dual-hosted git repository.

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 78657a2  [feature-diff] in order to replace an extension, it has to be removed from the prototype and added in the new, they will be merged otherwise
78657a2 is described below

commit 78657a24f105623c65bb82355150084e3cd6625b
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Fri Jun 21 17:21:57 2019 +0200

    [feature-diff] in order to replace an extension, it has to be removed
    from the prototype and added in the new, they will be merged otherwise
---
 .../apache/sling/feature/diff/impl/ExtensionsComparator.java  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
index dd3472d..f310724 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
@@ -64,6 +64,8 @@ public final class ExtensionsComparator extends AbstractFeatureElementComparator
     }
 
     protected void computeDiff(Extension previousExtension, Extension currentExtension, Feature target) {
+        boolean replace = false;
+
         switch (previousExtension.getType()) {
             case ARTIFACTS:
                 Extension targetExtension = new Extension(previousExtension.getType(), previousExtension.getName(), previousExtension.isRequired());
@@ -100,7 +102,7 @@ public final class ExtensionsComparator extends AbstractFeatureElementComparator
 
             case TEXT:
                 if (!previousExtension.getText().equals(currentExtension.getText())) {
-                    target.getExtensions().add(currentExtension);
+                    replace = true;
                 }
                 break;
 
@@ -113,7 +115,7 @@ public final class ExtensionsComparator extends AbstractFeatureElementComparator
                     JsonValue currentNode = parseJSON(currentJSON); 
 
                     if (!previousNode.equals(currentNode)) {
-                        target.getExtensions().add(currentExtension);
+                        replace = true;
                     }
                 } catch (Throwable t) {
                     // should not happen
@@ -129,6 +131,11 @@ public final class ExtensionsComparator extends AbstractFeatureElementComparator
             default:
                 break;
         }
+
+        if (replace) {
+            target.getPrototype().getConfigurationRemovals().add(currentExtension.getName());
+            target.getExtensions().add(currentExtension);
+        }
     }
 
     private static JsonValue parseJSON(String json) {