@bensandee/forgejo-cli 0.6.1 → 0.6.2
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/README.md +1 -1
- package/dist/bin.mjs +38 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ command takes `--json`, which prints exactly one JSON document, failures include
|
|
|
48
48
|
| `pr:list` | List a repository's pull requests |
|
|
49
49
|
| `commit:status` | Read the status checks for a commit SHA, branch, tag or git ref |
|
|
50
50
|
| `issue:*` | `view`, `list`, `comment`, `create`, `update`, `download`, `label`, `unlabel`, `set-labels`, `close`, `reopen` |
|
|
51
|
-
| `pr:create` | Push the current branch and open a pull request, deriving the title and body when none is given
|
|
51
|
+
| `pr:create` | Push the current branch and open a pull request, deriving the title and body when none is given; reports no closed-issue claims, which `bst pr:create` does |
|
|
52
52
|
| `pr:update` | Push the current branch and update its open pull request |
|
|
53
53
|
| `branch:list` | List a repository's branches |
|
|
54
54
|
| `branch:delete` | Delete a branch through the API; reports the forge's reason when it refuses |
|
package/dist/bin.mjs
CHANGED
|
@@ -160,7 +160,7 @@ function loadEnvFileForBin(rawArgs, bin, io = processIo) {
|
|
|
160
160
|
// src/version.ts
|
|
161
161
|
const parsed = z.object({ version: z.string() }).safeParse({
|
|
162
162
|
name: "@bensandee/forgejo-cli",
|
|
163
|
-
version: "0.6.
|
|
163
|
+
version: "0.6.2",
|
|
164
164
|
description: "bst-fj: Forgejo API commands without the rest of bst",
|
|
165
165
|
license: "MIT",
|
|
166
166
|
repository: {
|
|
@@ -1283,6 +1283,7 @@ z.array(z.unknown());
|
|
|
1283
1283
|
function branchNotFoundMessage(conn, branch) {
|
|
1284
1284
|
return `Branch ${branch} not found in ${conn.repository}`;
|
|
1285
1285
|
}
|
|
1286
|
+
z.object({ full_name: z.string() });
|
|
1286
1287
|
async function getBranchHeadSha(executor, conn, branch) {
|
|
1287
1288
|
const url = `${repoBase(conn)}/branches/${encodeURIComponent(branch)}`;
|
|
1288
1289
|
const res = await executor.fetch(url, { headers: authHeaders(conn) });
|
|
@@ -1665,6 +1666,36 @@ const commitStatusCommand = defineCommand({
|
|
|
1665
1666
|
process.exitCode = report.status === "green" ? 0 : 1;
|
|
1666
1667
|
}
|
|
1667
1668
|
});
|
|
1669
|
+
// ../forgejo/src/closing-refs.ts
|
|
1670
|
+
const CLOSING_REF = /(?:^|[\s([])(clos(?:e|es|ed)|fix(?:es|ed)?|resolv(?:e|es|ed))(?::[ \t]*|[ \t]+)((?:[\w.-]+\/[\w.-]+)?#\d+)(?![\w-])/gim;
|
|
1671
|
+
function capitalize(word) {
|
|
1672
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
1673
|
+
}
|
|
1674
|
+
function extractClosingRefs(messages) {
|
|
1675
|
+
const byIssue = /* @__PURE__ */ new Map();
|
|
1676
|
+
for (const message of messages) for (const [, keyword, issue] of message.matchAll(CLOSING_REF)) {
|
|
1677
|
+
if (keyword === void 0 || issue === void 0) continue;
|
|
1678
|
+
const key = issue.toLowerCase();
|
|
1679
|
+
if (!byIssue.has(key)) byIssue.set(key, {
|
|
1680
|
+
text: `${capitalize(keyword)} ${issue}`,
|
|
1681
|
+
issue
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
return [...byIssue.values()];
|
|
1685
|
+
}
|
|
1686
|
+
function closedIssues(text) {
|
|
1687
|
+
return new Set(extractClosingRefs([text]).map((ref) => ref.issue.toLowerCase()));
|
|
1688
|
+
}
|
|
1689
|
+
function droppedClosingRefs(messages, body) {
|
|
1690
|
+
const closed = closedIssues(body);
|
|
1691
|
+
return extractClosingRefs(messages).filter((ref) => !closed.has(ref.issue.toLowerCase()));
|
|
1692
|
+
}
|
|
1693
|
+
function carryForwardClosingRefs(source, target) {
|
|
1694
|
+
const missing = droppedClosingRefs([source], target);
|
|
1695
|
+
if (missing.length === 0) return target;
|
|
1696
|
+
const refLines = missing.map((ref) => ref.text).join("\n");
|
|
1697
|
+
return target.trim() === "" ? refLines : `${target}\n\n${refLines}`;
|
|
1698
|
+
}
|
|
1668
1699
|
// ../forgejo/src/fetcher.ts
|
|
1669
1700
|
const LONG_FETCH_TIMEOUT_MS = 6e5;
|
|
1670
1701
|
function morePagesFollow(res, pageLength, received, pageSize) {
|
|
@@ -4024,7 +4055,10 @@ async function findOpenPr(executor, conn, head, signal = null) {
|
|
|
4024
4055
|
const PullListItemSchema = z.object({
|
|
4025
4056
|
number: z.number(),
|
|
4026
4057
|
title: z.string().nullish(),
|
|
4027
|
-
head: z.object({
|
|
4058
|
+
head: z.object({
|
|
4059
|
+
ref: z.string(),
|
|
4060
|
+
repo: z.object({ full_name: z.string() }).nullish()
|
|
4061
|
+
}),
|
|
4028
4062
|
base: z.object({ ref: z.string() }).nullish(),
|
|
4029
4063
|
state: z.enum(["open", "closed"]),
|
|
4030
4064
|
merged: z.boolean().nullish(),
|
|
@@ -4069,6 +4103,7 @@ async function listPulls(executor, conn, options = {}) {
|
|
|
4069
4103
|
number: pr.number,
|
|
4070
4104
|
title: pr.title ?? null,
|
|
4071
4105
|
headRef: pr.head.ref,
|
|
4106
|
+
headRepo: pr.head.repo?.full_name ?? null,
|
|
4072
4107
|
baseRef: pr.base?.ref ?? null,
|
|
4073
4108
|
state: pr.state,
|
|
4074
4109
|
merged: pr.merged ?? pr.merged_at != null,
|
|
@@ -5796,36 +5831,6 @@ const prCloseCommand = defineCommand({
|
|
|
5796
5831
|
}
|
|
5797
5832
|
}
|
|
5798
5833
|
});
|
|
5799
|
-
// ../forgejo/src/closing-refs.ts
|
|
5800
|
-
const CLOSING_REF = /(?:^|[\s([])(clos(?:e|es|ed)|fix(?:es|ed)?|resolv(?:e|es|ed))(?::[ \t]*|[ \t]+)((?:[\w.-]+\/[\w.-]+)?#\d+)(?![\w-])/gim;
|
|
5801
|
-
function capitalize(word) {
|
|
5802
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
5803
|
-
}
|
|
5804
|
-
function extractClosingRefs(messages) {
|
|
5805
|
-
const byIssue = /* @__PURE__ */ new Map();
|
|
5806
|
-
for (const message of messages) for (const [, keyword, issue] of message.matchAll(CLOSING_REF)) {
|
|
5807
|
-
if (keyword === void 0 || issue === void 0) continue;
|
|
5808
|
-
const key = issue.toLowerCase();
|
|
5809
|
-
if (!byIssue.has(key)) byIssue.set(key, {
|
|
5810
|
-
text: `${capitalize(keyword)} ${issue}`,
|
|
5811
|
-
issue
|
|
5812
|
-
});
|
|
5813
|
-
}
|
|
5814
|
-
return [...byIssue.values()];
|
|
5815
|
-
}
|
|
5816
|
-
function closedIssues(text) {
|
|
5817
|
-
return new Set(extractClosingRefs([text]).map((ref) => ref.issue.toLowerCase()));
|
|
5818
|
-
}
|
|
5819
|
-
function droppedClosingRefs(messages, body) {
|
|
5820
|
-
const closed = closedIssues(body);
|
|
5821
|
-
return extractClosingRefs(messages).filter((ref) => !closed.has(ref.issue.toLowerCase()));
|
|
5822
|
-
}
|
|
5823
|
-
function carryForwardClosingRefs(source, target) {
|
|
5824
|
-
const missing = droppedClosingRefs([source], target);
|
|
5825
|
-
if (missing.length === 0) return target;
|
|
5826
|
-
const refLines = missing.map((ref) => ref.text).join("\n");
|
|
5827
|
-
return target.trim() === "" ? refLines : `${target}\n\n${refLines}`;
|
|
5828
|
-
}
|
|
5829
5834
|
// ../forgejo/src/git.ts
|
|
5830
5835
|
const GIT_LOCAL_TIMEOUT_MS = 6e4;
|
|
5831
5836
|
const GIT_WRITE_TIMEOUT_MS = 3e5;
|
|
@@ -6408,7 +6413,7 @@ const prCreateCommand = defineCommand({
|
|
|
6408
6413
|
},
|
|
6409
6414
|
json: {
|
|
6410
6415
|
type: "boolean",
|
|
6411
|
-
description: "Emit one JSON document: action (created | updated | would-create | would-update), number (or null), url (or null), branch, base, title, body, droppedRefs? ([{text, issue}]), dryRun. A create or would-create carries droppedRefs; on a dry run, number and url are null."
|
|
6416
|
+
description: "Emit one JSON document: action (created | updated | would-create | would-update), number (or null), url (or null), branch, base, title, body, droppedRefs? ([{text, issue}]), dryRun. A create or would-create carries droppedRefs; on a dry run, number and url are null. The document carries no claims member and no claim advice line: the closed-issue claim check reads the repo's .tooling.json and is bst pr:create's alone."
|
|
6412
6417
|
},
|
|
6413
6418
|
verbose: {
|
|
6414
6419
|
type: "boolean",
|