Skip to content

Commit 6bac18f

Browse files
committed
Only consider the first heading in comments
1 parent 5463075 commit 6bac18f

5 files changed

Lines changed: 174 additions & 78 deletions

File tree

dist/index.js

Lines changed: 76 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ function _objectWithoutProperties(source, excluded) {
16031603
return target;
16041604
}
16051605

1606-
const VERSION = "3.5.1";
1606+
const VERSION = "3.6.0";
16071607

16081608
const _excluded = ["authStrategy"];
16091609
class Octokit {
@@ -3617,7 +3617,7 @@ var isPlainObject = __nccwpck_require__(3287);
36173617
var nodeFetch = _interopDefault(__nccwpck_require__(467));
36183618
var requestError = __nccwpck_require__(537);
36193619

3620-
const VERSION = "5.6.2";
3620+
const VERSION = "5.6.3";
36213621

36223622
function getBufferResponse(response) {
36233623
return response.arrayBuffer();
@@ -5448,9 +5448,17 @@ AbortError.prototype = Object.create(Error.prototype);
54485448
AbortError.prototype.constructor = AbortError;
54495449
AbortError.prototype.name = 'AbortError';
54505450

5451+
const URL$1 = Url.URL || whatwgUrl.URL;
5452+
54515453
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
54525454
const PassThrough$1 = Stream.PassThrough;
5453-
const resolve_url = Url.resolve;
5455+
5456+
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
5457+
const orig = new URL$1(original).hostname;
5458+
const dest = new URL$1(destination).hostname;
5459+
5460+
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
5461+
};
54545462

54555463
/**
54565464
* Fetch function
@@ -5538,7 +5546,19 @@ function fetch(url, opts) {
55385546
const location = headers.get('Location');
55395547

55405548
// HTTP fetch step 5.3
5541-
const locationURL = location === null ? null : resolve_url(request.url, location);
5549+
let locationURL = null;
5550+
try {
5551+
locationURL = location === null ? null : new URL$1(location, request.url).toString();
5552+
} catch (err) {
5553+
// error here can only be invalid URL in Location: header
5554+
// do not throw when options.redirect == manual
5555+
// let the user extract the errorneous redirect URL
5556+
if (request.redirect !== 'manual') {
5557+
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
5558+
finalize();
5559+
return;
5560+
}
5561+
}
55425562

55435563
// HTTP fetch step 5.5
55445564
switch (request.redirect) {
@@ -5586,6 +5606,12 @@ function fetch(url, opts) {
55865606
size: request.size
55875607
};
55885608

5609+
if (!isDomainOrSubdomain(request.url, locationURL)) {
5610+
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
5611+
requestOpts.headers.delete(name);
5612+
}
5613+
}
5614+
55895615
// HTTP-redirect fetch step 9
55905616
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
55915617
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
@@ -8286,7 +8312,7 @@ __nccwpck_require__.d(__webpack_exports__, {
82868312
;// CONCATENATED MODULE: ./node_modules/marked/lib/marked.esm.js
82878313
/**
82888314
* marked - a markdown parser
8289-
* Copyright (c) 2011-2021, Christopher Jeffrey. (MIT Licensed)
8315+
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
82908316
* https://github.com/markedjs/marked
82918317
*/
82928318

@@ -8489,7 +8515,7 @@ function splitCells(tableRow, count) {
84898515

84908516
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
84918517
if (!cells[0].trim()) { cells.shift(); }
8492-
if (!cells[cells.length - 1].trim()) { cells.pop(); }
8518+
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
84938519

84948520
if (cells.length > count) {
84958521
cells.splice(count);
@@ -8641,14 +8667,11 @@ class Tokenizer {
86418667

86428668
space(src) {
86438669
const cap = this.rules.block.newline.exec(src);
8644-
if (cap) {
8645-
if (cap[0].length > 1) {
8646-
return {
8647-
type: 'space',
8648-
raw: cap[0]
8649-
};
8650-
}
8651-
return { raw: '\n' };
8670+
if (cap && cap[0].length > 0) {
8671+
return {
8672+
type: 'space',
8673+
raw: cap[0]
8674+
};
86528675
}
86538676
}
86548677

@@ -8872,7 +8895,24 @@ class Tokenizer {
88728895
for (i = 0; i < l; i++) {
88738896
this.lexer.state.top = false;
88748897
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
8875-
if (!list.loose && list.items[i].tokens.some(t => t.type === 'space')) {
8898+
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
8899+
const hasMultipleLineBreaks = spacers.every(t => {
8900+
const chars = t.raw.split('');
8901+
let lineBreaks = 0;
8902+
for (const char of chars) {
8903+
if (char === '\n') {
8904+
lineBreaks += 1;
8905+
}
8906+
if (lineBreaks > 1) {
8907+
return true;
8908+
}
8909+
}
8910+
8911+
return false;
8912+
});
8913+
8914+
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
8915+
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
88768916
list.loose = true;
88778917
list.items[i].loose = true;
88788918
}
@@ -8924,7 +8964,7 @@ class Tokenizer {
89248964
type: 'table',
89258965
header: splitCells(cap[1]).map(c => { return { text: c }; }),
89268966
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
8927-
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
8967+
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
89288968
};
89298969

89308970
if (item.header.length === item.align.length) {
@@ -9343,7 +9383,7 @@ const block = {
93439383
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
93449384
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
93459385
+ ')',
9346-
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
9386+
def: /^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
93479387
table: noopTest,
93489388
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
93499389
// regex template, placeholders will be replaced according to different paragraph
@@ -9352,7 +9392,7 @@ const block = {
93529392
text: /^[^\n]+/
93539393
};
93549394

9355-
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
9395+
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
93569396
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
93579397
block.def = edit(block.def)
93589398
.replace('label', block._label)
@@ -9480,8 +9520,8 @@ const inline = {
94809520
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
94819521
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
94829522
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
9483-
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
9484-
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
9523+
reflink: /^!?\[(label)\]\[(ref)\]/,
9524+
nolink: /^!?\[(ref)\](?:\[\])?/,
94859525
reflinkSearch: 'reflink|nolink(?!\\()',
94869526
emStrong: {
94879527
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
@@ -9548,6 +9588,11 @@ inline.link = edit(inline.link)
95489588

95499589
inline.reflink = edit(inline.reflink)
95509590
.replace('label', inline._label)
9591+
.replace('ref', block._label)
9592+
.getRegex();
9593+
9594+
inline.nolink = edit(inline.nolink)
9595+
.replace('ref', block._label)
95519596
.getRegex();
95529597

95539598
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
@@ -9763,7 +9808,11 @@ class Lexer {
97639808
// newline
97649809
if (token = this.tokenizer.space(src)) {
97659810
src = src.substring(token.raw.length);
9766-
if (token.type) {
9811+
if (token.raw.length === 1 && tokens.length > 0) {
9812+
// if there's a single \n as a spacer, it's terminating the last line,
9813+
// so move it there so that we don't get unecessary paragraph tags
9814+
tokens[tokens.length - 1].raw += '\n';
9815+
} else {
97679816
tokens.push(token);
97689817
}
97699818
continue;
@@ -10970,9 +11019,13 @@ async function categorize(comments, upstream, getRxns) {
1097011019
for (const comment of comments) {
1097111020
if (!comment.body)
1097211021
continue;
11022+
let foundHeading = false;
1097311023
for (const item of lexer(comment.body)) {
10974-
if (item.type !== 'heading')
11024+
if (item.type !== 'heading') {
11025+
if (foundHeading)
11026+
break;
1097511027
continue;
11028+
}
1097611029
const squished = squish(item.text);
1097711030
switch (squished) {
1097811031
case 'inspiration':
@@ -11015,6 +11068,7 @@ const [owner, repo] = slug.split('/');
1101511068
const issue_number = parseInt(((0,_actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput)('today') || process.env.GTD_TODAY));
1101611069
const token = (0,_actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput)('token');
1101711070
const octokit = _actions_github__WEBPACK_IMPORTED_MODULE_0__.getOctokit(token);
11071+
const comment_id = _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.payload.comment.id;
1101811072
const comments = await octokit.rest.issues.listComments({
1101911073
owner,
1102011074
repo,

0 commit comments

Comments
 (0)