-
Notifications
You must be signed in to change notification settings - Fork 1
Improved handling of dependency updates #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "changesets": minor | ||
| --- | ||
|
|
||
| Add support for handling dependency updates separately from other changesets, so that they can be presented in a more organised way. | ||
|
|
||
| This is utilized by setting the update type to `dependency` in place of major/minor/patch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
changesets-java/src/main/java/se/fortnox/changesets/DependencyUpdatesParser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package se.fortnox.changesets; | ||
|
|
||
| import com.vladsch.flexmark.ast.Paragraph; | ||
| import com.vladsch.flexmark.parser.Parser; | ||
| import com.vladsch.flexmark.util.ast.Document; | ||
| import com.vladsch.flexmark.util.ast.Node; | ||
| import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterable; | ||
| import org.slf4j.Logger; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.StreamSupport; | ||
|
|
||
| import static org.slf4j.LoggerFactory.getLogger; | ||
|
|
||
| public class DependencyUpdatesParser { | ||
| private static final Logger LOG = getLogger(DependencyUpdatesParser.class); | ||
|
|
||
| public List<String> parseDependencyChangeset(String change) { | ||
| Parser parser = Parser.builder().build(); | ||
| Document parsed = parser.parse(change); | ||
|
|
||
| if (!parsed.hasChildren()) { | ||
| return List.of(); | ||
| } | ||
|
|
||
| String nodeName = parsed.getFirstChild().getNodeName(); | ||
| if (!nodeName.equals("BulletList")) { | ||
| LOG.warn("Unexpected node type {}", nodeName); | ||
| System.out.println(); | ||
niklasga marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return List.of(); | ||
| } | ||
|
|
||
| ReversiblePeekingIterable<Node> dependencyNodes = parsed.getFirstChild().getChildren(); | ||
|
|
||
| return StreamSupport.stream(dependencyNodes.spliterator(), false) | ||
| .map(node -> { | ||
| Paragraph paragraph = (Paragraph)node.getChildOfType(Paragraph.class); | ||
| return paragraph.getChars().toString().trim(); | ||
| }) | ||
| .distinct() | ||
| .toList(); | ||
| } | ||
| } | ||
7 changes: 4 additions & 3 deletions
7
changesets-java/src/main/java/se/fortnox/changesets/Level.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
changesets-java/src/test/java/se/fortnox/changesets/CompareTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package se.fortnox.changesets; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class CompareTest { | ||
| @Test | ||
| void shouldGenerateChangelogForReactiveWizard(@TempDir Path tempDir) throws IOException { | ||
| Path changesetsPath = Path.of("src/test/resources/changesets/reactive-wizard/.changeset"); | ||
|
|
||
| Path changesetsTarget = tempDir.resolve(".changeset"); | ||
| changesetsTarget.toFile().mkdir(); | ||
|
|
||
| String[] files = changesetsPath.toFile().list(); | ||
| for (String file : files) { | ||
| Files.copy(changesetsPath.resolve(file), changesetsTarget.resolve(file)); | ||
| } | ||
|
|
||
| assertThat(changesetsTarget.toFile().list()) | ||
| .isNotEmpty() | ||
| .containsExactly(changesetsPath.toFile().list()); | ||
|
|
||
| ChangelogAggregator changelog = new ChangelogAggregator(tempDir); | ||
| Path changelogFile = changelog.mergeChangesetsToChangelog("reactivewizard-parent", "26.0.0"); | ||
|
|
||
| String actualChangelogText = Files.readString(changelogFile); | ||
| String expectedChangelogText = Files.readString(changesetsPath.resolve("../CHANGELOG-expected.md")); | ||
|
|
||
| assertThat(actualChangelogText) | ||
| .isEqualTo(expectedChangelogText); | ||
|
|
||
| } | ||
| @Test | ||
| void shouldGenerateChangelogForReactiveWizardWithDependencyTypes(@TempDir Path tempDir) throws IOException { | ||
| Path changesetsPath = Path.of("src/test/resources/changesets/reactive-wizard-with-dependencies/.changeset"); | ||
|
|
||
| Path changesetsTarget = tempDir.resolve(".changeset"); | ||
| changesetsTarget.toFile().mkdir(); | ||
|
|
||
| String[] files = changesetsPath.toFile().list(); | ||
| for (String file : files) { | ||
| Files.copy(changesetsPath.resolve(file), changesetsTarget.resolve(file)); | ||
| } | ||
|
|
||
| assertThat(changesetsTarget.toFile().list()) | ||
| .isNotEmpty() | ||
| .containsExactly(changesetsPath.toFile().list()); | ||
|
|
||
| ChangelogAggregator changelog = new ChangelogAggregator(tempDir); | ||
| Path changelogFile = changelog.mergeChangesetsToChangelog("reactivewizard-parent", "26.0.0"); | ||
|
|
||
| String actualChangelogText = Files.readString(changelogFile); | ||
| String expectedChangelogText = Files.readString(changesetsPath.resolve("../CHANGELOG-expected.md")); | ||
|
|
||
| assertThat(actualChangelogText) | ||
| .isEqualTo(expectedChangelogText); | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.