mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-13 20:21:13 +00:00
Add ignore empty input
This commit is contained in:
parent
1d46172340
commit
db01d1ad6c
6 changed files with 78 additions and 20 deletions
|
|
@ -9,6 +9,8 @@ beforeEach(() => {
|
||||||
process.env["INPUT_HIDE_CLASSIFY"] = "OUTDATED"
|
process.env["INPUT_HIDE_CLASSIFY"] = "OUTDATED"
|
||||||
process.env["INPUT_HIDE_DETAILS"] = "false"
|
process.env["INPUT_HIDE_DETAILS"] = "false"
|
||||||
process.env["INPUT_GITHUB_TOKEN"] = "some-token"
|
process.env["INPUT_GITHUB_TOKEN"] = "some-token"
|
||||||
|
process.env["INPUT_IGNORE_EMPTY"] = "false"
|
||||||
|
process.env["INPUT_FOLLOW_SYMBOLIC_LINKS"] = "false"
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
@ -27,6 +29,8 @@ afterEach(() => {
|
||||||
delete process.env["INPUT_HIDE_DETAILS"]
|
delete process.env["INPUT_HIDE_DETAILS"]
|
||||||
delete process.env["INPUT_GITHUB_TOKEN"]
|
delete process.env["INPUT_GITHUB_TOKEN"]
|
||||||
delete process.env["INPUT_PATH"]
|
delete process.env["INPUT_PATH"]
|
||||||
|
delete process.env["INPUT_IGNORE_EMPTY"]
|
||||||
|
delete process.env["INPUT_FOLLOW_SYMBOLIC_LINKS"]
|
||||||
})
|
})
|
||||||
|
|
||||||
test("repo", async () => {
|
test("repo", async () => {
|
||||||
|
|
@ -42,7 +46,8 @@ test("repo", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -59,7 +64,8 @@ test("header", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -76,7 +82,8 @@ test("append", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -93,7 +100,8 @@ test("recreate", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -110,7 +118,8 @@ test("delete", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -127,7 +136,8 @@ test("hideOldComment", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -144,7 +154,8 @@ test("hideAndRecreate", async () => {
|
||||||
hideAndRecreate: true,
|
hideAndRecreate: true,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -161,7 +172,8 @@ test("hideClassify", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OFF_TOPIC",
|
hideClassify: "OFF_TOPIC",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -178,7 +190,8 @@ test("hideDetails", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: true,
|
hideDetails: true,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -196,7 +209,8 @@ describe("path", () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("hi there\n")
|
expect(await require("../src/config").getBody()).toEqual("hi there\n")
|
||||||
})
|
})
|
||||||
|
|
@ -214,7 +228,8 @@ describe("path", () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual(
|
expect(await require("../src/config").getBody()).toEqual(
|
||||||
"hi there\n\nhey there\n"
|
"hi there\n\nhey there\n"
|
||||||
|
|
@ -234,7 +249,8 @@ describe("path", () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("")
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
})
|
})
|
||||||
|
|
@ -253,7 +269,27 @@ test("message", async () => {
|
||||||
hideAndRecreate: false,
|
hideAndRecreate: false,
|
||||||
hideClassify: "OUTDATED",
|
hideClassify: "OUTDATED",
|
||||||
hideDetails: false,
|
hideDetails: false,
|
||||||
githubToken: "some-token"
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: false
|
||||||
})
|
})
|
||||||
expect(await require("../src/config").getBody()).toEqual("hello there")
|
expect(await require("../src/config").getBody()).toEqual("hello there")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("ignore_empty", async () => {
|
||||||
|
process.env["INPUT_IGNORE_EMPTY"] = "true"
|
||||||
|
expect(require("../src/config")).toMatchObject({
|
||||||
|
pullRequestNumber: expect.any(Number),
|
||||||
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
|
header: "",
|
||||||
|
append: false,
|
||||||
|
recreate: false,
|
||||||
|
deleteOldComment: false,
|
||||||
|
hideOldComment: false,
|
||||||
|
hideAndRecreate: false,
|
||||||
|
hideClassify: "OUTDATED",
|
||||||
|
hideDetails: false,
|
||||||
|
githubToken: "some-token",
|
||||||
|
ignoreEmpty: true
|
||||||
|
})
|
||||||
|
expect(await require("../src/config").getBody()).toEqual("")
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,13 @@ inputs:
|
||||||
path:
|
path:
|
||||||
description: "glob path to file(s) containing comment message"
|
description: "glob path to file(s) containing comment message"
|
||||||
required: false
|
required: false
|
||||||
follow-symbolic-links:
|
ignore_empty:
|
||||||
|
description: "Indicates whether to ignore missing or empty messages"
|
||||||
|
default: "true"
|
||||||
|
required: false
|
||||||
|
follow_symbolic_links:
|
||||||
description: "Indicates whether to follow symbolic links for path"
|
description: "Indicates whether to follow symbolic links for path"
|
||||||
|
default: "false"
|
||||||
required: false
|
required: false
|
||||||
number:
|
number:
|
||||||
description: "pull request number for push event"
|
description: "pull request number for push event"
|
||||||
|
|
|
||||||
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
|
|
@ -207,7 +207,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.githubToken = exports.hideOldComment = 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.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);
|
||||||
|
|
@ -230,6 +230,9 @@ exports.hideClassify = core.getInput("hide_classify", {
|
||||||
exports.deleteOldComment = core.getBooleanInput("delete", { required: true });
|
exports.deleteOldComment = core.getBooleanInput("delete", { 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", {
|
||||||
|
required: true
|
||||||
|
});
|
||||||
function buildRepo() {
|
function buildRepo() {
|
||||||
return {
|
return {
|
||||||
owner: github_1.context.repo.owner,
|
owner: github_1.context.repo.owner,
|
||||||
|
|
@ -239,7 +242,9 @@ function buildRepo() {
|
||||||
function getBody() {
|
function getBody() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const pathInput = core.getMultilineInput("path", { required: false });
|
const pathInput = core.getMultilineInput("path", { required: false });
|
||||||
const followSymbolicLinks = core.getInput("follow-symbolic-links").toLocaleUpperCase() !== "FALSE";
|
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
|
||||||
|
required: true
|
||||||
|
});
|
||||||
if (pathInput && pathInput.length > 0) {
|
if (pathInput && pathInput.length > 0) {
|
||||||
try {
|
try {
|
||||||
const globber = yield (0, glob_1.create)(pathInput.join("\n"), {
|
const globber = yield (0, glob_1.create)(pathInput.join("\n"), {
|
||||||
|
|
@ -317,6 +322,9 @@ function run() {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const body = yield (0, config_1.getBody)();
|
const body = yield (0, config_1.getBody)();
|
||||||
|
if (!body && config_1.ignoreEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!config_1.deleteOldComment && !config_1.hideOldComment && !body) {
|
if (!config_1.deleteOldComment && !config_1.hideOldComment && !body) {
|
||||||
throw new Error("Either message or path input is required");
|
throw new Error("Either message or path input is required");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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
|
|
@ -24,6 +24,9 @@ export const hideClassify = core.getInput("hide_classify", {
|
||||||
export const deleteOldComment = core.getBooleanInput("delete", {required: true})
|
export const deleteOldComment = core.getBooleanInput("delete", {required: true})
|
||||||
export const hideOldComment = core.getBooleanInput("hide", {required: true})
|
export const hideOldComment = core.getBooleanInput("hide", {required: true})
|
||||||
export const githubToken = core.getInput("GITHUB_TOKEN", {required: true})
|
export const githubToken = core.getInput("GITHUB_TOKEN", {required: true})
|
||||||
|
export const ignoreEmpty = core.getBooleanInput("ignore_empty", {
|
||||||
|
required: true
|
||||||
|
})
|
||||||
|
|
||||||
function buildRepo(): {repo: string; owner: string} {
|
function buildRepo(): {repo: string; owner: string} {
|
||||||
return {
|
return {
|
||||||
|
|
@ -34,8 +37,9 @@ function buildRepo(): {repo: string; owner: string} {
|
||||||
|
|
||||||
export async function getBody(): Promise<string> {
|
export async function getBody(): Promise<string> {
|
||||||
const pathInput = core.getMultilineInput("path", {required: false})
|
const pathInput = core.getMultilineInput("path", {required: false})
|
||||||
const followSymbolicLinks =
|
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
|
||||||
core.getInput("follow-symbolic-links").toLocaleUpperCase() !== "FALSE"
|
required: true
|
||||||
|
})
|
||||||
if (pathInput && pathInput.length > 0) {
|
if (pathInput && pathInput.length > 0) {
|
||||||
try {
|
try {
|
||||||
const globber = await create(pathInput.join("\n"), {
|
const globber = await create(pathInput.join("\n"), {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import {
|
||||||
hideOldComment,
|
hideOldComment,
|
||||||
pullRequestNumber,
|
pullRequestNumber,
|
||||||
recreate,
|
recreate,
|
||||||
repo
|
repo,
|
||||||
|
ignoreEmpty
|
||||||
} from "./config"
|
} from "./config"
|
||||||
import {
|
import {
|
||||||
createComment,
|
createComment,
|
||||||
|
|
@ -32,6 +33,10 @@ async function run(): Promise<undefined> {
|
||||||
try {
|
try {
|
||||||
const body = await getBody()
|
const body = await getBody()
|
||||||
|
|
||||||
|
if (!body && ignoreEmpty) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!deleteOldComment && !hideOldComment && !body) {
|
if (!deleteOldComment && !hideOldComment && !body) {
|
||||||
throw new Error("Either message or path input is required")
|
throw new Error("Either message or path input is required")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue