Skip to content

Commit

Permalink
chore(uniquet): add uniquet job to add the single ET file 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias-vandaele committed Nov 10, 2024
1 parent 5d4a267 commit bf0eefe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public ElementTemplateIterator(Repository repository, RevCommit commit) {
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(this.commit.getTree());
treeWalk.setRecursive(false);
// treeWalk.setFilter(PathFilter.create("connectors"));
this.initialWalk = treeWalk;
this.initialWalk.next();
} catch (IOException e) {
Expand All @@ -82,10 +81,14 @@ private static String findCurrentConnectorRuntime(Repository repository, RevComm
try (StringReader reader = new StringReader(pomContent)) {
MavenXpp3Reader mavenReader = new MavenXpp3Reader();
Model model = mavenReader.read(reader);
return model.getParent().getVersion();
String[] version = model.getParent().getVersion().split("\\.");
return "^" + version[0] + "." + version[1];
}
} catch (IOException | XmlPullParserException | NullPointerException e) {
log.error("Commit: " + commit.getName() + ". No connector runtime found");
} catch (IOException
| XmlPullParserException
| NullPointerException
| IndexOutOfBoundsException e) {
log.error("Commit: {}. No connector runtime found", commit.getName());
return "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
Expand Down Expand Up @@ -80,11 +81,19 @@ private void analyzeCommit(RevCommit commit) {
if (result.containsKey(elementTemplateFile.elementTemplate().id())) {
result
.get(elementTemplateFile.elementTemplate().id())
.putIfAbsent(
.compute(
elementTemplateFile.elementTemplate().version(),
new VersionValue(
RAW_GITHUB_LINK.formatted(commit.getName(), elementTemplateFile.path()),
elementTemplateFile.connectorRuntime()));
(integer, versionValue) ->
Optional.ofNullable(versionValue)
.map(
vv ->
new VersionValue(
vv.link(), elementTemplateFile.connectorRuntime()))
.orElse(
new VersionValue(
RAW_GITHUB_LINK.formatted(
commit.getName(), elementTemplateFile.path()),
elementTemplateFile.connectorRuntime())));
} else {
Map<Integer, VersionValue> version = new HashMap<>();
version.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void crawl() throws IOException, GitAPIException {

// Verification that the version 2 is the last commit
Assertions.assertTrue(map.get("test").get(2).link().contains(revCommit3.getName()));
Assertions.assertTrue(map.get("test").get(2).connectorRuntime().equals("9.9"));
Assertions.assertTrue(map.get("test").get(2).connectorRuntime().equals("^9.9"));
// Verification that the version 1 is the last commit containing version 1
Assertions.assertTrue(map.get("test").get(1).link().contains(revCommit2.getName()));
Assertions.assertFalse(map.get("test").get(1).link().contains(revCommit1.getName()));
Expand Down

0 comments on commit bf0eefe

Please sign in to comment.