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/dist-cli/index.js
CHANGED
|
@@ -1829,6 +1829,7 @@ const codeowners_1 = __nccwpck_require__(586);
|
|
|
1829
1829
|
const git_1 = __nccwpck_require__(243);
|
|
1830
1830
|
const github_1 = __nccwpck_require__(248);
|
|
1831
1831
|
const ghcli_1 = __nccwpck_require__(64);
|
|
1832
|
+
const pr_template_1 = __nccwpck_require__(456);
|
|
1832
1833
|
function formatTemplate(tpl, vars) {
|
|
1833
1834
|
let out = tpl;
|
|
1834
1835
|
for (const [k, v] of Object.entries(vars))
|
|
@@ -1948,8 +1949,22 @@ async function runSplit(config, logger) {
|
|
|
1948
1949
|
(0, git_1.pushBranch)(config.remoteName, branch, worktreeDir);
|
|
1949
1950
|
const ownersStr = b.owners.length ? b.owners.join(", ") : "(unowned)";
|
|
1950
1951
|
const filesStr = b.files.map(f => `- ${f.file}`).join("\n");
|
|
1952
|
+
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 });
|
|
1951
1953
|
const title = formatTemplate(config.prTitle, { owners: ownersStr, bucket_key: b.key });
|
|
1952
|
-
|
|
1954
|
+
let body;
|
|
1955
|
+
if (config.prBodyMode === "none") {
|
|
1956
|
+
body = undefined;
|
|
1957
|
+
}
|
|
1958
|
+
else if (config.prBodyMode === "custom") {
|
|
1959
|
+
body = formatTemplate(config.prBody, { owners: ownersStr, bucket_key: b.key, files: filesStr });
|
|
1960
|
+
}
|
|
1961
|
+
else {
|
|
1962
|
+
const template = (0, pr_template_1.readPrTemplate)(worktreeDir, config.prTemplatePath) ?? "";
|
|
1963
|
+
body =
|
|
1964
|
+
config.prBodyMode === "template_with_bucket"
|
|
1965
|
+
? (template ? template.trimEnd() + "\n\n---\n\n" + bucketInfo : bucketInfo)
|
|
1966
|
+
: (template || bucketInfo);
|
|
1967
|
+
}
|
|
1953
1968
|
const pr = useGhCli
|
|
1954
1969
|
? (() => {
|
|
1955
1970
|
return (0, ghcli_1.upsertPullRequestViaGh)({
|
|
@@ -1957,7 +1972,7 @@ async function runSplit(config, logger) {
|
|
|
1957
1972
|
base: baseBranch,
|
|
1958
1973
|
head: branch,
|
|
1959
1974
|
title,
|
|
1960
|
-
body,
|
|
1975
|
+
body: body ?? "",
|
|
1961
1976
|
draft: config.draft,
|
|
1962
1977
|
bucketKey: b.key
|
|
1963
1978
|
});
|
|
@@ -1968,7 +1983,7 @@ async function runSplit(config, logger) {
|
|
|
1968
1983
|
base: baseBranch,
|
|
1969
1984
|
head: branch,
|
|
1970
1985
|
title,
|
|
1971
|
-
body,
|
|
1986
|
+
body: body ?? "",
|
|
1972
1987
|
draft: config.draft,
|
|
1973
1988
|
bucketKey: b.key
|
|
1974
1989
|
});
|
|
@@ -2469,13 +2484,47 @@ async function upsertPullRequest(params) {
|
|
|
2469
2484
|
head,
|
|
2470
2485
|
base,
|
|
2471
2486
|
title,
|
|
2472
|
-
body,
|
|
2487
|
+
body: body || "",
|
|
2473
2488
|
draft
|
|
2474
2489
|
});
|
|
2475
2490
|
return { bucket_key: bucketKey, branch: head, number: created.data.number, url: created.data.html_url };
|
|
2476
2491
|
}
|
|
2477
2492
|
|
|
2478
2493
|
|
|
2494
|
+
/***/ }),
|
|
2495
|
+
|
|
2496
|
+
/***/ 456:
|
|
2497
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
2498
|
+
|
|
2499
|
+
"use strict";
|
|
2500
|
+
|
|
2501
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2502
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2503
|
+
};
|
|
2504
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2505
|
+
exports.readPrTemplate = readPrTemplate;
|
|
2506
|
+
const node_fs_1 = __importDefault(__nccwpck_require__(24));
|
|
2507
|
+
const node_path_1 = __importDefault(__nccwpck_require__(760));
|
|
2508
|
+
function readPrTemplate(cwd, templatePath) {
|
|
2509
|
+
const candidates = [];
|
|
2510
|
+
if (templatePath && templatePath.trim()) {
|
|
2511
|
+
candidates.push(templatePath.trim());
|
|
2512
|
+
}
|
|
2513
|
+
else {
|
|
2514
|
+
candidates.push(".github/pull_request_template.md");
|
|
2515
|
+
candidates.push(".github/PULL_REQUEST_TEMPLATE.md");
|
|
2516
|
+
candidates.push("pull_request_template.md");
|
|
2517
|
+
}
|
|
2518
|
+
for (const rel of candidates) {
|
|
2519
|
+
const abs = node_path_1.default.resolve(cwd, rel);
|
|
2520
|
+
if (node_fs_1.default.existsSync(abs) && node_fs_1.default.statSync(abs).isFile()) {
|
|
2521
|
+
return node_fs_1.default.readFileSync(abs, "utf8");
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
return null;
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
|
|
2479
2528
|
/***/ }),
|
|
2480
2529
|
|
|
2481
2530
|
/***/ 421:
|
|
@@ -13307,6 +13356,8 @@ function printHelp() {
|
|
|
13307
13356
|
" --commit-message <msg> (default: chore: automated changes)",
|
|
13308
13357
|
" --pr-title <tpl> Supports {owners} and {bucket_key}",
|
|
13309
13358
|
" --pr-body <tpl> Supports {owners}, {bucket_key}, {files}",
|
|
13359
|
+
" --pr-body-mode <mode> custom|template|template_with_bucket|none (default: custom)",
|
|
13360
|
+
" --pr-template-path <path> (default: .github/pull_request_template.md)",
|
|
13310
13361
|
" --draft <true|false> (default: false)",
|
|
13311
13362
|
"",
|
|
13312
13363
|
"Examples:",
|
|
@@ -13355,6 +13406,8 @@ async function main() {
|
|
|
13355
13406
|
let commitMessage = "chore: automated changes";
|
|
13356
13407
|
let prTitle = "chore: automated changes ({owners})";
|
|
13357
13408
|
let prBody = "Automated changes bucketed by CODEOWNERS.\n\nOwners: {owners}\nBucket key: {bucket_key}\n\nFiles:\n{files}\n";
|
|
13409
|
+
let prBodyMode = "template";
|
|
13410
|
+
let prTemplatePath = ".github/pull_request_template.md";
|
|
13358
13411
|
let draft = false;
|
|
13359
13412
|
// parse args
|
|
13360
13413
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -13394,6 +13447,10 @@ async function main() {
|
|
|
13394
13447
|
prTitle = takeArg(argv, i++, a);
|
|
13395
13448
|
else if (a === "--pr-body")
|
|
13396
13449
|
prBody = takeArg(argv, i++, a);
|
|
13450
|
+
else if (a === "--pr-body-mode")
|
|
13451
|
+
prBodyMode = takeArg(argv, i++, a);
|
|
13452
|
+
else if (a === "--pr-template-path")
|
|
13453
|
+
prTemplatePath = takeArg(argv, i++, a);
|
|
13397
13454
|
else if (a === "--draft")
|
|
13398
13455
|
draft = (0, buckets_2.parseBool)(takeArg(argv, i++, a));
|
|
13399
13456
|
else if (a.startsWith("-"))
|
|
@@ -13417,6 +13474,8 @@ async function main() {
|
|
|
13417
13474
|
commitMessage,
|
|
13418
13475
|
prTitle,
|
|
13419
13476
|
prBody,
|
|
13477
|
+
prBodyMode,
|
|
13478
|
+
prTemplatePath,
|
|
13420
13479
|
draft,
|
|
13421
13480
|
remoteName: "origin"
|
|
13422
13481
|
};
|