Unverified Commit b19798c8 authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

ci/github-script/commits: keep formatting for diffs of markdown blocks

Previously, when the diff contained a context line with ```, this would
end the code block and entirely break the markdown rendering.

Now we use the html code blocks provided by `core.summary` and properly
escape the content, so that it never escapes via html tags.
parent 40dcbb14
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -179,9 +179,14 @@ module.exports = async function ({ github, context, core }) {
        }

        core.summary.addRaw('<details><summary>Show diff</summary>')
        core.summary.addRaw('\n\n```diff', true)
        core.summary.addRaw(truncated.join('\n'), true)
        core.summary.addRaw('```', true)
        core.summary.addCodeBlock(
          truncated
            .join('\n')
            .replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;'),
          'diff',
        )
        core.summary.addRaw('</details>')
      }