From d75f3e97ff92025c184cc84606a8438f01862bcb Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 8 Feb 2021 11:42:42 +0100 Subject: [PATCH] fixup! tools: add GitHub Action linter for pr-url --- .github/workflows/linters.yml | 2 +- tools/lint-pr-url.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index c35f4ddc11b2c9..9bb9cd14bc1d0f 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -105,5 +105,5 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 2 - # GH Actions squash all commits into one, HEAD^ refers to the base branch. + # GH Actions squashes all PR commits, HEAD^ refers to the base branch. - run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }} diff --git a/tools/lint-pr-url.mjs b/tools/lint-pr-url.mjs index 5f6781b21dd889..3b491d26e389cb 100755 --- a/tools/lint-pr-url.mjs +++ b/tools/lint-pr-url.mjs @@ -13,11 +13,11 @@ const fileDelimiter = /^\+\+\+ b\/(.+\.md)$/; const changeDelimiter = /^@@ -\d+,\d+ \+(\d+),\d+ @@/; const prUrlDefinition = /^\+\s+pr-url: (.+)$/; +const validatePrUrl = (url) => url == null || url === expectedPrUrl; + let currentFile; let currentLine; -const validatePrUrl = (url) => url == null || url === expectedPrUrl; - const diff = readline.createInterface({ input: process.stdin }); for await (const line of diff) { if (fileDelimiter.test(line)) {