-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MergeYaml does not process multiline scalar value blocks properly whe…
…n multiline block is located in a subkey (#4728) * Add `upgradeSlackNotificationVersion2` test for MergeYaml * Improve MergeYamlVisitor for multiline value scalars * Revert space * Remove linebreak helper methods from StringUtils + use more inlining * Keep `LINE_BREAK` private in StringUtils * Make `substringOfBeforeFirstLineBreak` and `substringOfAfterFirstLineBreak` private
- Loading branch information
1 parent
287e247
commit d2c0087
Showing
5 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -29,4 +29,5 @@ | |
public class MultilineScalarChanged implements Marker { | ||
UUID id; | ||
boolean added; | ||
int indent; | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -1511,12 +1511,16 @@ void addLiteralStyleBlockWhichDoesAlreadyExist() { | |
void addLiteralStyleBlock() { | ||
rewriteRun( | ||
spec -> spec | ||
.recipe(new MergeYaml("$.some.very.deep.object", | ||
.recipe(new MergeYaml("$.some.very", | ||
// language=yaml | ||
""" | ||
script: | | ||
#!/bin/bash | ||
echo "hello" | ||
deep: | ||
object: | ||
script: | # yaml comment | ||
#!/bin/bash | ||
echo "hello" | ||
echo "hello" | ||
""", | ||
false, "name", | ||
null)), | ||
|
@@ -1534,9 +1538,63 @@ void addLiteralStyleBlock() { | |
deep: | ||
object: | ||
with: An existing value | ||
script: | | ||
#!/bin/bash | ||
echo "hello" | ||
script: | # yaml comment | ||
#!/bin/bash | ||
echo "hello" | ||
echo "hello" | ||
""") | ||
); | ||
} | ||
|
||
@Test | ||
// Mimics `org.openrewrite.github.UpgradeSlackNotificationVersion2Test` | ||
void upgradeSlackNotificationVersion2() { | ||
rewriteRun( | ||
spec -> spec | ||
.recipe(new MergeYaml("$..steps[?(@.uses =~ 'slackapi/slack-github-action@v1.*')]", | ||
// language=yaml | ||
""" | ||
with: | ||
method: chat.postMessage | ||
token: ${{ secrets.SLACK_MORTY_BOT_TOKEN }} | ||
payload: | | ||
channel: "##foo-alerts" | ||
text: ":boom: Unable run dependency check on: <${{ steps.get_failed_check_link.outputs.failed-check-link }}|${{ inputs.organization }}/${{ inputs.repository }}>" | ||
""", | ||
false, "name", | ||
null)), | ||
yaml( | ||
""" | ||
jobs: | ||
build: | ||
steps: | ||
- name: Send notification on error | ||
if: failure() && inputs.send-notification | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: "##foo-alerts" | ||
slack-message: ":boom: Unable run dependency check on: <${{ steps.get_failed_check_link.outputs.failed-check-link }}|${{ inputs.organization }}/${{ inputs.repository }}>" | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_MORTY_BOT_TOKEN }} | ||
""", | ||
""" | ||
jobs: | ||
build: | ||
steps: | ||
- name: Send notification on error | ||
if: failure() && inputs.send-notification | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: "##foo-alerts" | ||
slack-message: ":boom: Unable run dependency check on: <${{ steps.get_failed_check_link.outputs.failed-check-link }}|${{ inputs.organization }}/${{ inputs.repository }}>" | ||
method: chat.postMessage | ||
token: ${{ secrets.SLACK_MORTY_BOT_TOKEN }} | ||
payload: | | ||
channel: "##foo-alerts" | ||
text: ":boom: Unable run dependency check on: <${{ steps.get_failed_check_link.outputs.failed-check-link }}|${{ inputs.organization }}/${{ inputs.repository }}>" | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_MORTY_BOT_TOKEN }} | ||
""") | ||
); | ||
} | ||
|