split-by-codeowners 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action.yml +10 -0
- package/dist/index.js +55 -4
- package/dist/index.js.map +1 -1
- package/dist-cli/index.js +63 -4
- package/dist-cli/index.js.map +1 -1
- package/package.json +1 -1
package/action.yml
CHANGED
|
@@ -91,6 +91,16 @@ inputs:
|
|
|
91
91
|
required: false
|
|
92
92
|
default: "Automated changes bucketed by CODEOWNERS.\n\nOwners: {owners}\nBucket key: {bucket_key}\n\nFiles:\n{files}\n"
|
|
93
93
|
|
|
94
|
+
pr_body_mode:
|
|
95
|
+
description: "PR body mode for PR creation: custom | template | template_with_bucket | none"
|
|
96
|
+
required: false
|
|
97
|
+
default: "template"
|
|
98
|
+
|
|
99
|
+
pr_template_path:
|
|
100
|
+
description: "Path to pull request template file (used when pr_body_mode=template*)."
|
|
101
|
+
required: false
|
|
102
|
+
default: ".github/pull_request_template.md"
|
|
103
|
+
|
|
94
104
|
draft:
|
|
95
105
|
description: "Create PRs as drafts."
|
|
96
106
|
required: false
|
package/dist/index.js
CHANGED
|
@@ -27470,6 +27470,7 @@ const codeowners_1 = __nccwpck_require__(3586);
|
|
|
27470
27470
|
const git_1 = __nccwpck_require__(1243);
|
|
27471
27471
|
const github_1 = __nccwpck_require__(9248);
|
|
27472
27472
|
const ghcli_1 = __nccwpck_require__(8064);
|
|
27473
|
+
const pr_template_1 = __nccwpck_require__(2456);
|
|
27473
27474
|
function formatTemplate(tpl, vars) {
|
|
27474
27475
|
let out = tpl;
|
|
27475
27476
|
for (const [k, v] of Object.entries(vars))
|
|
@@ -27589,8 +27590,22 @@ async function runSplit(config, logger) {
|
|
|
27589
27590
|
(0, git_1.pushBranch)(config.remoteName, branch, worktreeDir);
|
|
27590
27591
|
const ownersStr = b.owners.length ? b.owners.join(", ") : "(unowned)";
|
|
27591
27592
|
const filesStr = b.files.map(f => `- ${f.file}`).join("\n");
|
|
27593
|
+
const bucketInfo = formatTemplate("Automated changes bucketed by CODEOWNERS.\n\nOwners: {owners}\nBucket key: {bucket_key}\n\nFiles:\n{files}\n", { owners: ownersStr, bucket_key: b.key, files: filesStr });
|
|
27592
27594
|
const title = formatTemplate(config.prTitle, { owners: ownersStr, bucket_key: b.key });
|
|
27593
|
-
|
|
27595
|
+
let body;
|
|
27596
|
+
if (config.prBodyMode === "none") {
|
|
27597
|
+
body = undefined;
|
|
27598
|
+
}
|
|
27599
|
+
else if (config.prBodyMode === "custom") {
|
|
27600
|
+
body = formatTemplate(config.prBody, { owners: ownersStr, bucket_key: b.key, files: filesStr });
|
|
27601
|
+
}
|
|
27602
|
+
else {
|
|
27603
|
+
const template = (0, pr_template_1.readPrTemplate)(worktreeDir, config.prTemplatePath) ?? "";
|
|
27604
|
+
body =
|
|
27605
|
+
config.prBodyMode === "template_with_bucket"
|
|
27606
|
+
? (template ? template.trimEnd() + "\n\n---\n\n" + bucketInfo : bucketInfo)
|
|
27607
|
+
: (template || bucketInfo);
|
|
27608
|
+
}
|
|
27594
27609
|
const pr = useGhCli
|
|
27595
27610
|
? (() => {
|
|
27596
27611
|
return (0, ghcli_1.upsertPullRequestViaGh)({
|
|
@@ -27598,7 +27613,7 @@ async function runSplit(config, logger) {
|
|
|
27598
27613
|
base: baseBranch,
|
|
27599
27614
|
head: branch,
|
|
27600
27615
|
title,
|
|
27601
|
-
body,
|
|
27616
|
+
body: body ?? "",
|
|
27602
27617
|
draft: config.draft,
|
|
27603
27618
|
bucketKey: b.key
|
|
27604
27619
|
});
|
|
@@ -27609,7 +27624,7 @@ async function runSplit(config, logger) {
|
|
|
27609
27624
|
base: baseBranch,
|
|
27610
27625
|
head: branch,
|
|
27611
27626
|
title,
|
|
27612
|
-
body,
|
|
27627
|
+
body: body ?? "",
|
|
27613
27628
|
draft: config.draft,
|
|
27614
27629
|
bucketKey: b.key
|
|
27615
27630
|
});
|
|
@@ -28110,7 +28125,7 @@ async function upsertPullRequest(params) {
|
|
|
28110
28125
|
head,
|
|
28111
28126
|
base,
|
|
28112
28127
|
title,
|
|
28113
|
-
body,
|
|
28128
|
+
body: body || "",
|
|
28114
28129
|
draft
|
|
28115
28130
|
});
|
|
28116
28131
|
return { bucket_key: bucketKey, branch: head, number: created.data.number, url: created.data.html_url };
|
|
@@ -28182,6 +28197,8 @@ async function run() {
|
|
|
28182
28197
|
prTitle: core.getInput("pr_title") || "chore: automated changes ({owners})",
|
|
28183
28198
|
prBody: core.getInput("pr_body") ||
|
|
28184
28199
|
"Automated changes bucketed by CODEOWNERS.\n\nOwners: {owners}\nBucket key: {bucket_key}\n\nFiles:\n{files}\n",
|
|
28200
|
+
prBodyMode: (core.getInput("pr_body_mode") || "custom"),
|
|
28201
|
+
prTemplatePath: core.getInput("pr_template_path") || ".github/pull_request_template.md",
|
|
28185
28202
|
draft: (0, buckets_1.parseBool)(core.getInput("draft")),
|
|
28186
28203
|
remoteName: "origin",
|
|
28187
28204
|
};
|
|
@@ -28198,6 +28215,40 @@ async function run() {
|
|
|
28198
28215
|
run();
|
|
28199
28216
|
|
|
28200
28217
|
|
|
28218
|
+
/***/ }),
|
|
28219
|
+
|
|
28220
|
+
/***/ 2456:
|
|
28221
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
28222
|
+
|
|
28223
|
+
"use strict";
|
|
28224
|
+
|
|
28225
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28226
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28227
|
+
};
|
|
28228
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
28229
|
+
exports.readPrTemplate = readPrTemplate;
|
|
28230
|
+
const node_fs_1 = __importDefault(__nccwpck_require__(3024));
|
|
28231
|
+
const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
|
28232
|
+
function readPrTemplate(cwd, templatePath) {
|
|
28233
|
+
const candidates = [];
|
|
28234
|
+
if (templatePath && templatePath.trim()) {
|
|
28235
|
+
candidates.push(templatePath.trim());
|
|
28236
|
+
}
|
|
28237
|
+
else {
|
|
28238
|
+
candidates.push(".github/pull_request_template.md");
|
|
28239
|
+
candidates.push(".github/PULL_REQUEST_TEMPLATE.md");
|
|
28240
|
+
candidates.push("pull_request_template.md");
|
|
28241
|
+
}
|
|
28242
|
+
for (const rel of candidates) {
|
|
28243
|
+
const abs = node_path_1.default.resolve(cwd, rel);
|
|
28244
|
+
if (node_fs_1.default.existsSync(abs) && node_fs_1.default.statSync(abs).isFile()) {
|
|
28245
|
+
return node_fs_1.default.readFileSync(abs, "utf8");
|
|
28246
|
+
}
|
|
28247
|
+
}
|
|
28248
|
+
return null;
|
|
28249
|
+
}
|
|
28250
|
+
|
|
28251
|
+
|
|
28201
28252
|
/***/ }),
|
|
28202
28253
|
|
|
28203
28254
|
/***/ 2613:
|