mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-13 04:01:14 +00:00
📦️ build
This commit is contained in:
parent
db8c408d3e
commit
efaaab3fd4
3 changed files with 41 additions and 11 deletions
|
|
@ -254,12 +254,27 @@ describe("getBodyOf", () => {
|
||||||
|
|
||||||
describe("commentsEqual", () => {
|
describe("commentsEqual", () => {
|
||||||
test.each([
|
test.each([
|
||||||
{ body: "body", previous: "body\n<!-- Sticky Pull Request Commentheader -->", header: "header", expected: true },
|
{
|
||||||
{ body: "body", previous: "body\n<!-- Sticky Pull Request Comment -->", header: "", expected: true },
|
body: "body",
|
||||||
{ body: "body", previous: "body\n<!-- Sticky Pull Request Commenta different header -->", header: "header", expected: false },
|
previous: "body\n<!-- Sticky Pull Request Commentheader -->",
|
||||||
{ body: "body", previous: "body", header: "header", expected: false },
|
header: "header",
|
||||||
{ body: "body", previous: "", header: "header", expected: false },
|
expected: true
|
||||||
{ body: "", previous: "body", header: "header", expected: false },
|
},
|
||||||
|
{
|
||||||
|
body: "body",
|
||||||
|
previous: "body\n<!-- Sticky Pull Request Comment -->",
|
||||||
|
header: "",
|
||||||
|
expected: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
body: "body",
|
||||||
|
previous: "body\n<!-- Sticky Pull Request Commenta different header -->",
|
||||||
|
header: "header",
|
||||||
|
expected: false
|
||||||
|
},
|
||||||
|
{body: "body", previous: "body", header: "header", expected: false},
|
||||||
|
{body: "body", previous: "", header: "header", expected: false},
|
||||||
|
{body: "", previous: "body", header: "header", expected: false}
|
||||||
])("commentsEqual(%s, %s, %s)", ({body, previous, header, expected}) => {
|
])("commentsEqual(%s, %s, %s)", ({body, previous, header, expected}) => {
|
||||||
expect(commentsEqual(body, previous, header)).toEqual(expected)
|
expect(commentsEqual(body, previous, header)).toEqual(expected)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
23
dist/index.js
generated
vendored
23
dist/index.js
generated
vendored
|
|
@ -39,11 +39,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getBodyOf = exports.minimizeComment = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
exports.commentsEqual = exports.getBodyOf = exports.minimizeComment = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
function headerComment(header) {
|
function headerComment(header) {
|
||||||
return `<!-- Sticky Pull Request Comment${header} -->`;
|
return `<!-- Sticky Pull Request Comment${header} -->`;
|
||||||
}
|
}
|
||||||
|
function bodyWithHeader(body, header) {
|
||||||
|
return `${body}\n${headerComment(header)}`;
|
||||||
|
}
|
||||||
function findPreviousComment(octokit, repo, number, header) {
|
function findPreviousComment(octokit, repo, number, header) {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -113,7 +116,7 @@ function updateComment(octokit, id, body, header, previousBody) {
|
||||||
id,
|
id,
|
||||||
body: previousBody
|
body: previousBody
|
||||||
? `${previousBody}\n${body}`
|
? `${previousBody}\n${body}`
|
||||||
: `${body}\n${headerComment(header)}`
|
: bodyWithHeader(body, header)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -127,7 +130,7 @@ function createComment(octokit, repo, issue_number, body, header, previousBody)
|
||||||
}
|
}
|
||||||
return yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody
|
return yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody
|
||||||
? `${previousBody}\n${body}`
|
? `${previousBody}\n${body}`
|
||||||
: `${body}\n${headerComment(header)}` }));
|
: bodyWithHeader(body, header) }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.createComment = createComment;
|
exports.createComment = createComment;
|
||||||
|
|
@ -166,6 +169,11 @@ function getBodyOf(previous, append, hideDetails) {
|
||||||
return (_a = previous.body) === null || _a === void 0 ? void 0 : _a.replace(/(<details.*?)\s*\bopen\b(.*>)/g, "$1$2");
|
return (_a = previous.body) === null || _a === void 0 ? void 0 : _a.replace(/(<details.*?)\s*\bopen\b(.*>)/g, "$1$2");
|
||||||
}
|
}
|
||||||
exports.getBodyOf = getBodyOf;
|
exports.getBodyOf = getBodyOf;
|
||||||
|
function commentsEqual(body, previous, header) {
|
||||||
|
const newBody = bodyWithHeader(body, header);
|
||||||
|
return newBody === previous;
|
||||||
|
}
|
||||||
|
exports.commentsEqual = commentsEqual;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
@ -209,7 +217,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
};
|
};
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getBody = exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.pullRequestNumber = void 0;
|
exports.getBody = exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.skipUnchanged = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.pullRequestNumber = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github_1 = __nccwpck_require__(5438);
|
const github_1 = __nccwpck_require__(5438);
|
||||||
const fs_1 = __nccwpck_require__(7147);
|
const fs_1 = __nccwpck_require__(7147);
|
||||||
|
|
@ -236,6 +244,9 @@ exports.onlyCreateComment = core.getBooleanInput("only_create", {
|
||||||
exports.onlyUpdateComment = core.getBooleanInput("only_update", {
|
exports.onlyUpdateComment = core.getBooleanInput("only_update", {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
exports.skipUnchanged = core.getBooleanInput("skip_unchanged", {
|
||||||
|
required: true
|
||||||
|
});
|
||||||
exports.hideOldComment = core.getBooleanInput("hide", { required: true });
|
exports.hideOldComment = core.getBooleanInput("hide", { required: true });
|
||||||
exports.githubToken = core.getInput("GITHUB_TOKEN", { required: true });
|
exports.githubToken = core.getInput("GITHUB_TOKEN", { required: true });
|
||||||
exports.ignoreEmpty = core.getBooleanInput("ignore_empty", {
|
exports.ignoreEmpty = core.getBooleanInput("ignore_empty", {
|
||||||
|
|
@ -372,6 +383,10 @@ function run() {
|
||||||
yield (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
yield (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (config_1.skipUnchanged && (0, comment_1.commentsEqual)(body, previous.body, config_1.header)) {
|
||||||
|
// don't recreate or update if the message is unchanged
|
||||||
|
return;
|
||||||
|
}
|
||||||
const previousBody = (0, comment_1.getBodyOf)(previous, config_1.append, config_1.hideDetails);
|
const previousBody = (0, comment_1.getBodyOf)(previous, config_1.append, config_1.hideDetails);
|
||||||
if (config_1.recreate) {
|
if (config_1.recreate) {
|
||||||
yield (0, comment_1.deleteComment)(octokit, previous.id);
|
yield (0, comment_1.deleteComment)(octokit, previous.id);
|
||||||
|
|
|
||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue