xmvn/0001-Prefer-namespaced-metadata-when-duplicates-are-found.patch
2019-07-01 12:35:16 +02:00

60 lines
2.2 KiB
Diff

From 1474fd57e606bdb00417524a7b648f7841b014c8 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 28 Jun 2019 12:15:23 +0200
Subject: [PATCH 1/3] Prefer namespaced metadata when duplicates are found
---
.../metadata/impl/DefaultMetadataResult.java | 33 +++++++++++--------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/metadata/impl/DefaultMetadataResult.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/metadata/impl/DefaultMetadataResult.java
index c8b63214..67bafef5 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/metadata/impl/DefaultMetadataResult.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/metadata/impl/DefaultMetadataResult.java
@@ -94,23 +94,28 @@ class DefaultMetadataResult
}
ArtifactMetadata otherMetadata = artifactMap.get( artifact );
- if ( otherMetadata != null )
+
+ if ( otherMetadata == null )
+ {
+ artifactMap.put( artifact, metadata );
+ continue;
+ }
+
+ duplicateArtifacts.add( artifact );
+
+ if ( ignoreDuplicates )
{
- duplicateArtifacts.add( artifact );
-
- if ( ignoreDuplicates )
- {
- artifactMap.remove( artifact );
- logger.warn( "Ignoring metadata for artifact {} as it has duplicate metadata", artifact );
- continue;
- }
- else
- {
- logger.warn( "Duplicate metadata for artifact {}", artifact );
- }
+ artifactMap.remove( artifact );
+ logger.warn( "Ignoring metadata for artifact {} as it has duplicate metadata", artifact );
+ continue;
}
- artifactMap.put( artifact, metadata );
+ logger.warn( "Duplicate metadata for artifact {}", artifact );
+
+ if ( otherMetadata.getNamespace().isEmpty() || !metadata.getNamespace().isEmpty() )
+ {
+ artifactMap.put( artifact, metadata );
+ }
}
}
--
2.21.0