mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
update
This commit is contained in:
parent
c5c6fc78b5
commit
cdb9c56467
Binary file not shown.
@ -81,15 +81,15 @@ public class APIDiff {
|
|||||||
|
|
||||||
Map<String, File> prevJars = getJars(prev);
|
Map<String, File> prevJars = getJars(prev);
|
||||||
Map<String, File> currJars = getJars(curr);
|
Map<String, File> currJars = getJars(curr);
|
||||||
|
Set<String> combined = new HashSet<>(prevJars.keySet());
|
||||||
|
combined.addAll(currJars.keySet());
|
||||||
|
|
||||||
List<Pair<File, File>> retMapping = new ArrayList<>();
|
List<Pair<File, File>> retMapping = new ArrayList<>();
|
||||||
|
|
||||||
for (String prevKey : (Iterable<String>) prevJars.keySet().stream().sorted(StringUtils::compareIgnoreCase)::iterator) {
|
for (String prevKey : (Iterable<String>) combined.stream().sorted(StringUtils::compareIgnoreCase)::iterator) {
|
||||||
File prevFile = prevJars.get(prevKey);
|
File prevFile = prevJars.get(prevKey);
|
||||||
File curFile = currJars.get(prevKey);
|
File curFile = currJars.get(prevKey);
|
||||||
if (prevFile != null && curFile != null) {
|
retMapping.add(Pair.of(prevFile, curFile));
|
||||||
retMapping.add(Pair.of(prevFile, curFile));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retMapping;
|
return retMapping;
|
||||||
|
@ -56,24 +56,43 @@ public class Main {
|
|||||||
|
|
||||||
for (Pair<File, File> prevCurJars : APIDiff.getCommonJars(cliArgs.getPreviousVersPath(), cliArgs.getCurrentVersPath())) {
|
for (Pair<File, File> prevCurJars : APIDiff.getCommonJars(cliArgs.getPreviousVersPath(), cliArgs.getCurrentVersPath())) {
|
||||||
try {
|
try {
|
||||||
ModuleVersionNumbers prevVersionNums = ModuleUpdates.getVersionsFromJar(prevCurJars.getLeft());
|
File previous = prevCurJars.getLeft();
|
||||||
|
File current = prevCurJars.getRight();
|
||||||
|
|
||||||
ComparisonRecord record = APIDiff.getComparison(
|
// if no current, then we can't update; just continue
|
||||||
cliArgs.getPreviousVersion(),
|
if (current == null || !current.exists()) {
|
||||||
cliArgs.getCurrentVersion(),
|
if (previous != null) {
|
||||||
prevCurJars.getLeft(),
|
LOGGER.log(Level.WARNING, "No matching current jar found for previous jar: " + previous);
|
||||||
prevCurJars.getRight());
|
}
|
||||||
|
continue;
|
||||||
ModuleVersionNumbers projectedVersionNums = ModuleUpdates.getModuleVersionUpdate(prevVersionNums, record.getChangeType());
|
|
||||||
|
|
||||||
String jarFileName;
|
|
||||||
if (prevCurJars.getLeft().getName().equalsIgnoreCase(prevCurJars.getRight().getName())) {
|
|
||||||
jarFileName = prevCurJars.getLeft().getName();
|
|
||||||
} else {
|
|
||||||
jarFileName = MessageFormat.format("[previous: {0}, current: {1}]", prevCurJars.getLeft().getName(), prevCurJars.getRight().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputDiff(jarFileName, record, prevVersionNums, projectedVersionNums);
|
String jarFileName = current.getName();
|
||||||
|
|
||||||
|
ModuleVersionNumbers projectedVersionNums;
|
||||||
|
if (previous == null || !previous.exists()) {
|
||||||
|
projectedVersionNums = ModuleVersionNumbers.getNewModule(current.getName());
|
||||||
|
outputNewModule(jarFileName, projectedVersionNums);
|
||||||
|
} else {
|
||||||
|
ModuleVersionNumbers prevVersionNums = ModuleUpdates.getVersionsFromJar(prevCurJars.getLeft());
|
||||||
|
|
||||||
|
ComparisonRecord record = APIDiff.getComparison(
|
||||||
|
cliArgs.getPreviousVersion(),
|
||||||
|
cliArgs.getCurrentVersion(),
|
||||||
|
prevCurJars.getLeft(),
|
||||||
|
prevCurJars.getRight());
|
||||||
|
|
||||||
|
projectedVersionNums = ModuleUpdates.getModuleVersionUpdate(prevVersionNums, record.getChangeType());
|
||||||
|
outputDiff(jarFileName, record, prevVersionNums, projectedVersionNums);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous.getName().equalsIgnoreCase(current.getName())) {
|
||||||
|
jarFileName = previous.getName();
|
||||||
|
} else {
|
||||||
|
jarFileName = MessageFormat.format("[previous: {0}, current: {1}]", previous.getName(), current.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
newVersionNumMapping.put(projectedVersionNums.getRelease().getModuleName(), projectedVersionNums);
|
newVersionNumMapping.put(projectedVersionNums.getRelease().getModuleName(), projectedVersionNums);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -135,4 +154,35 @@ public class Main {
|
|||||||
record.getHumanReadableApiChange()
|
record.getHumanReadableApiChange()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs new jar file name.
|
||||||
|
*
|
||||||
|
* @param jarFileName The jar file name.
|
||||||
|
* @param projectedVersionNums The calculated version numbers for current
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
|
private static void outputNewModule(
|
||||||
|
String jarFileName,
|
||||||
|
ModuleVersionNumbers projectedVersionNums
|
||||||
|
) {
|
||||||
|
LOGGER.log(Level.INFO, MessageFormat.format("""
|
||||||
|
|
||||||
|
====================================
|
||||||
|
NEW MODULE: {0}
|
||||||
|
Current Version Numbers:
|
||||||
|
- release: {1}
|
||||||
|
- specification: {2}
|
||||||
|
- implementation: {3}
|
||||||
|
====================================
|
||||||
|
|
||||||
|
|
||||||
|
""",
|
||||||
|
jarFileName,
|
||||||
|
projectedVersionNums.getRelease().getFullReleaseStr(),
|
||||||
|
projectedVersionNums.getSpec().getSemVerStr(),
|
||||||
|
projectedVersionNums.getImplementation()
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,14 @@ public class ModuleUpdates {
|
|||||||
public static ModuleVersionNumbers getModuleVersionUpdate(ModuleVersionNumbers prev, PublicApiChangeType apiChangeType) {
|
public static ModuleVersionNumbers getModuleVersionUpdate(ModuleVersionNumbers prev, PublicApiChangeType apiChangeType) {
|
||||||
switch (apiChangeType) {
|
switch (apiChangeType) {
|
||||||
case NONE -> {
|
case NONE -> {
|
||||||
|
return new ModuleVersionNumbers(
|
||||||
|
prev.getModuleName(),
|
||||||
|
prev.getSpec(),
|
||||||
|
prev.getImplementation(),
|
||||||
|
prev.getRelease()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case INTERNAL_CHANGE -> {
|
||||||
return new ModuleVersionNumbers(
|
return new ModuleVersionNumbers(
|
||||||
prev.getModuleName(),
|
prev.getModuleName(),
|
||||||
prev.getSpec(),
|
prev.getSpec(),
|
||||||
@ -236,10 +244,7 @@ public class ModuleUpdates {
|
|||||||
prev.getSpec().getPatch()
|
prev.getSpec().getPatch()
|
||||||
),
|
),
|
||||||
prev.getImplementation() + 1,
|
prev.getImplementation() + 1,
|
||||||
new ReleaseVal(
|
prev.getRelease()
|
||||||
prev.getRelease().getModuleName(),
|
|
||||||
prev.getRelease().getReleaseVersion()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case INCOMPATIBLE_CHANGE -> {
|
case INCOMPATIBLE_CHANGE -> {
|
||||||
@ -247,8 +252,8 @@ public class ModuleUpdates {
|
|||||||
prev.getModuleName(),
|
prev.getModuleName(),
|
||||||
new SemVer(
|
new SemVer(
|
||||||
prev.getSpec().getMajor() + 1,
|
prev.getSpec().getMajor() + 1,
|
||||||
prev.getSpec().getMinor(),
|
0,
|
||||||
prev.getSpec().getPatch()
|
null
|
||||||
),
|
),
|
||||||
prev.getImplementation() + 1,
|
prev.getImplementation() + 1,
|
||||||
new ReleaseVal(
|
new ReleaseVal(
|
||||||
@ -585,6 +590,19 @@ public class ModuleUpdates {
|
|||||||
*/
|
*/
|
||||||
public static class ModuleVersionNumbers {
|
public static class ModuleVersionNumbers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns ModuleVersionNumbers for a brand new module.
|
||||||
|
* @param moduleName The module name.
|
||||||
|
* @return The module version numbers
|
||||||
|
*/
|
||||||
|
public static ModuleVersionNumbers getNewModule(String moduleName) {
|
||||||
|
return new ModuleVersionNumbers(
|
||||||
|
moduleName,
|
||||||
|
new SemVer(1, 0, null),
|
||||||
|
1,
|
||||||
|
new ReleaseVal(moduleName.replaceAll("-", "."), 1));
|
||||||
|
}
|
||||||
|
|
||||||
private final String moduleName;
|
private final String moduleName;
|
||||||
private final SemVer spec;
|
private final SemVer spec;
|
||||||
private final int implementation;
|
private final int implementation;
|
||||||
|
@ -25,7 +25,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
* A public API change type (no change, compatible change, incompatible change).
|
* A public API change type (no change, compatible change, incompatible change).
|
||||||
*/
|
*/
|
||||||
public enum PublicApiChangeType implements Comparator<PublicApiChangeType> {
|
public enum PublicApiChangeType implements Comparator<PublicApiChangeType> {
|
||||||
NONE(0), COMPATIBLE_CHANGE(1), INCOMPATIBLE_CHANGE(2);
|
NONE(0), INTERNAL_CHANGE(1), COMPATIBLE_CHANGE(2), INCOMPATIBLE_CHANGE(3);
|
||||||
|
|
||||||
private final int level;
|
private final int level;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user