Skip to content

Commit

Permalink
Reviewed comparison
Browse files Browse the repository at this point in the history
- added changes to default template
- handled null values
- added logs
  • Loading branch information
egoettelmann committed Sep 6, 2022
1 parent e55c018 commit 64c7634
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ public ArtifactMetadata report(final List<AggregatedPropertyMetadata> aggregate)
try {
final Artifact previousArtifact = this.repositoryService.resolvePreviousStableVersion(this.project);
if (previousArtifact != null) {
this.log.info("Comparing with previous stable version: " + previousArtifact.getVersion());
final MetadataComparator comparator = new MetadataComparator(this.log, aggregate);
final List<AggregatedPropertyMetadata> previous = this.aggregationService.load(previousArtifact);
final ArtifactMetadata.Changes changes = comparator.compare(previous, previousArtifact.getVersion());
metadata.setChanges(changes);
} else {
this.log.info("No previous stable version found to compare");
}
} catch (final MetadataFileNotFoundException e) {
this.log.warn("No aggregation file found for previous version, skipping comparison");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.core.model.AggregatedPropertyMetadata;
import com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.core.model.ArtifactMetadata;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.logging.Log;

import java.util.ArrayList;
Expand Down Expand Up @@ -72,10 +73,10 @@ public ArtifactMetadata.Changes compare(
}

private boolean hasChanged(final AggregatedPropertyMetadata current, final AggregatedPropertyMetadata previous) {
if (!current.getType().equalsIgnoreCase(previous.getType())) {
if (!StringUtils.equalsIgnoreCase(current.getType(), previous.getType())) {
return true;
}
if (!current.getDefaultValue().equalsIgnoreCase(previous.getDefaultValue())) {
if (!StringUtils.equalsIgnoreCase(current.getDefaultValue(), previous.getDefaultValue())) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,48 @@
</#if>
</tbody>
</table>

<#if metadata.changes??>
<table class="overviewChanges" border="0" cellpadding="3" cellspacing="0"
summary="Configuration properties table, listing metadata">
<caption><span>Configuration properties changes from version <span>${(metadata.changes.baseVersion)!}</span></span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Name</th>
<th class="colLast" scope="col">Change type</th>
</tr>
<tbody>
<#list metadata.changes.added as property>
<tr class="${property?is_even_item?then('altColor','rowColor')}">
<td class="colFirst">
<small>
<code>${property}</code>
</small>
</td>
<td class="colLast">ADDED</td>
</tr>
</#list>
<#list metadata.changes.updated as property>
<tr class="${property?is_even_item?then('altColor','rowColor')}">
<td class="colFirst">
<small>
<code>${property}</code>
</small>
</td>
<td class="colLast">UPDATED</td>
</tr>
</#list>
<#list metadata.changes.deleted as property>
<tr class="${property?is_even_item?then('altColor','rowColor')}">
<td class="colFirst">
<small>
<code>${property}</code>
</small>
</td>
<td class="colLast">DELETED</td>
</tr>
</#list>
</tbody>
</table>
</#if>
</body>
</html>

0 comments on commit 64c7634

Please sign in to comment.