From 01d6015e99fe7279b086fa3bfe3045c9daa907d8 Mon Sep 17 00:00:00 2001 From: Jason O'Conal Date: Tue, 30 Aug 2022 16:39:45 +0930 Subject: [PATCH] fix: more logging Add more logging to try to determine why the PR comes through in a way that we can't find the blank line before the Jira reference Version 1.0.9 Relates to SRE-225 --- package.json | 2 +- src/lint.js | 4 ++++ test-success.js | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test-success.js diff --git a/package.json b/package.json index 6c9c329..bcda262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-pr-linter", - "version": "1.0.7", + "version": "1.0.9", "description": "Finder's GitHub commit linter, runs as a GitHub Action", "main": "index.js", "scripts": { diff --git a/src/lint.js b/src/lint.js index c9a4de6..59c2f3d 100644 --- a/src/lint.js +++ b/src/lint.js @@ -34,6 +34,10 @@ module.exports = function (body, title, failureCallback, infoCallback) { // Ensure that there is a blank line before the Jira reference infoCallback('Checking PR body empty line'); if (bodyLines[bodyLines.length - 2] !== '') { + for (let i = 0; i < bodyLines.length; i++) { + infoCallback('Body line ' + i + ': ' + bodyLines[i]); + } + failureCallback( 'Invalid PR body. Needs a blank line before the Jira reference. ' + '(Expected blank line, found ' + bodyLines[bodyLines.length - 2] + ')' diff --git a/test-success.js b/test-success.js new file mode 100644 index 0000000..b704c8d --- /dev/null +++ b/test-success.js @@ -0,0 +1,10 @@ +const lint = require('./src/lint.js'); + +const title = 'chore: reinstate PR linter'; +const body = `Upgrading to v1.0.6 which should fix the issue where PR descriptions +like this one were failing the check: +https://github.com/finderau/site/pull/5057 + +Relates to SRE-225`; + +lint(body, title, console.error, console.log);