@cnzgray/dsh-mattpocock-workflow 0.2.0 → 0.4.0
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/lib/index.js
CHANGED
|
@@ -680,6 +680,7 @@ var AUTHOR_FIELDS = {
|
|
|
680
680
|
displayName: "full_name",
|
|
681
681
|
avatarUrl: "avatar_url"
|
|
682
682
|
};
|
|
683
|
+
var PART_OF_LINE = /^part of #(\d+)$/i;
|
|
683
684
|
var STATUS_LINE = /^HTTP\/\S+\s+(\d{3})/m;
|
|
684
685
|
var TOTAL_LINE = /^x-total-count:\s*(\d+)\s*$/im;
|
|
685
686
|
function parseApiResponse(stdout, stderr) {
|
|
@@ -731,6 +732,8 @@ function parseIssue(value, index, avatarBaseUrl2) {
|
|
|
731
732
|
const state = readState2(value.state, number);
|
|
732
733
|
const closedAt = readClosedAt(value.closed_at, number);
|
|
733
734
|
const url = readWebUrl(value.html_url);
|
|
735
|
+
const body = typeof value.body === "string" ? value.body : "";
|
|
736
|
+
const parent = readParent(body, number);
|
|
734
737
|
return {
|
|
735
738
|
ticket: {
|
|
736
739
|
ref: `#${String(number)}`,
|
|
@@ -745,11 +748,21 @@ function parseIssue(value, index, avatarBaseUrl2) {
|
|
|
745
748
|
openBlockers: 0,
|
|
746
749
|
blockedBy: [],
|
|
747
750
|
...closedAt === void 0 ? {} : { closedAt },
|
|
748
|
-
...url === void 0 ? {} : { url }
|
|
751
|
+
...url === void 0 ? {} : { url },
|
|
752
|
+
...parent === void 0 ? {} : { parent }
|
|
749
753
|
},
|
|
750
|
-
body
|
|
754
|
+
body
|
|
751
755
|
};
|
|
752
756
|
}
|
|
757
|
+
function readParent(body, number) {
|
|
758
|
+
const first = body.split(/\r?\n/).find((line) => line.trim().length > 0);
|
|
759
|
+
if (first === void 0) return void 0;
|
|
760
|
+
const match = PART_OF_LINE.exec(first.trim());
|
|
761
|
+
if (match === null) return void 0;
|
|
762
|
+
const parent = Number(match[1]);
|
|
763
|
+
if (!Number.isSafeInteger(parent) || parent <= 0 || parent === number) return void 0;
|
|
764
|
+
return `#${String(parent)}`;
|
|
765
|
+
}
|
|
753
766
|
function readState2(value, number) {
|
|
754
767
|
if (value === "open") return "open";
|
|
755
768
|
if (value === "closed") return "closed";
|
|
@@ -1948,17 +1961,61 @@ async function readIssue(deps, workspaceRoot, repository, number) {
|
|
|
1948
1961
|
ensureDetailSuccess(response, "\u8BFB\u53D6 Gitea \u5DE5\u5355\u8BE6\u60C5");
|
|
1949
1962
|
return parseIssue3(response.body);
|
|
1950
1963
|
}
|
|
1964
|
+
var MAX_COMMENT_PAGES = 200;
|
|
1951
1965
|
async function readComments(deps, workspaceRoot, repository, number) {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
const
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1966
|
+
const collected = /* @__PURE__ */ new Map();
|
|
1967
|
+
const absorb = (entries) => {
|
|
1968
|
+
let added = 0;
|
|
1969
|
+
for (const entry of entries) {
|
|
1970
|
+
const key = commentKey(entry);
|
|
1971
|
+
if (collected.has(key)) continue;
|
|
1972
|
+
collected.set(key, entry.comment);
|
|
1973
|
+
added += 1;
|
|
1974
|
+
}
|
|
1975
|
+
return added;
|
|
1976
|
+
};
|
|
1977
|
+
const finish = () => sortCommentsByTime([...collected.values()]);
|
|
1978
|
+
const first = await readCommentsPage(deps, workspaceRoot, repository, number, 1);
|
|
1979
|
+
absorb(first.entries);
|
|
1980
|
+
if (first.total !== void 0 && collected.size >= first.total) return finish();
|
|
1981
|
+
if (first.entries.length < deps.pageSize) return finish();
|
|
1982
|
+
const second = await readCommentsPage(deps, workspaceRoot, repository, number, 2);
|
|
1983
|
+
if (absorb(second.entries) === 0) return finish();
|
|
1984
|
+
const total = first.total;
|
|
1985
|
+
if (total === void 0) {
|
|
1986
|
+
for (let page = 3; page <= MAX_COMMENT_PAGES; page += 1) {
|
|
1987
|
+
const next = await readCommentsPage(deps, workspaceRoot, repository, number, page);
|
|
1988
|
+
const added = absorb(next.entries);
|
|
1989
|
+
if (added === 0) break;
|
|
1990
|
+
if (next.total !== void 0 && collected.size >= next.total) break;
|
|
1991
|
+
if (next.entries.length < deps.pageSize) break;
|
|
1992
|
+
}
|
|
1993
|
+
return finish();
|
|
1994
|
+
}
|
|
1995
|
+
const lastPage = Math.min(Math.ceil(total / deps.pageSize), MAX_COMMENT_PAGES);
|
|
1996
|
+
const rest = Array.from({ length: Math.max(0, lastPage - 2) }, (_, index) => index + 3);
|
|
1997
|
+
const pages = await mapWithConcurrency(
|
|
1998
|
+
rest,
|
|
1999
|
+
deps.concurrency,
|
|
2000
|
+
(page) => readCommentsPage(deps, workspaceRoot, repository, number, page)
|
|
2001
|
+
);
|
|
2002
|
+
for (const page of pages) absorb(page.entries);
|
|
2003
|
+
return finish();
|
|
2004
|
+
}
|
|
2005
|
+
async function readCommentsPage(deps, workspaceRoot, repository, number, page) {
|
|
2006
|
+
const endpoint = `/repos/${repository.owner}/${repository.name}/issues/${String(number)}/comments?page=${String(page)}&limit=${String(deps.pageSize)}`;
|
|
2007
|
+
const response = await callGiteaApi(deps.run, workspaceRoot, endpoint);
|
|
2008
|
+
ensureDetailSuccess(response, "\u8BFB\u53D6 Gitea \u5DE5\u5355\u8BC4\u8BBA");
|
|
2009
|
+
return { entries: parseCommentsPage(response.body), total: response.total };
|
|
2010
|
+
}
|
|
2011
|
+
function commentKey(entry) {
|
|
2012
|
+
if (entry.id !== null) return `id\0${String(entry.id)}`;
|
|
2013
|
+
return [
|
|
2014
|
+
"content",
|
|
2015
|
+
entry.comment.createdAt ?? "",
|
|
2016
|
+
entry.comment.author ?? "",
|
|
2017
|
+
entry.comment.body
|
|
2018
|
+
].join("\0");
|
|
1962
2019
|
}
|
|
1963
2020
|
async function readCurrentLogin(run, workspaceRoot) {
|
|
1964
2021
|
const response = await callGiteaApi(run, workspaceRoot, "/user");
|
|
@@ -2001,9 +2058,12 @@ function parseCommentsPage(body) {
|
|
|
2001
2058
|
const text = typeof entry.body === "string" ? entry.body : "";
|
|
2002
2059
|
if (text.length === 0) continue;
|
|
2003
2060
|
comments.push({
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2061
|
+
id: typeof entry.id === "number" ? entry.id : null,
|
|
2062
|
+
comment: {
|
|
2063
|
+
author: isRecord(entry.user) ? readOptionalString(entry.user.login) : null,
|
|
2064
|
+
body: text,
|
|
2065
|
+
createdAt: readOptionalString(entry.created_at)
|
|
2066
|
+
}
|
|
2007
2067
|
});
|
|
2008
2068
|
}
|
|
2009
2069
|
return comments;
|
|
@@ -2107,7 +2167,7 @@ function createGiteaTracker(deps) {
|
|
|
2107
2167
|
deps.concurrency ?? DEFAULT_CONCURRENCY,
|
|
2108
2168
|
DEFAULT_CONCURRENCY
|
|
2109
2169
|
);
|
|
2110
|
-
const detailDeps = { run: deps.run, pageSize };
|
|
2170
|
+
const detailDeps = { run: deps.run, pageSize, concurrency };
|
|
2111
2171
|
return {
|
|
2112
2172
|
async fetchSnapshot(workspaceRoot, windowLimit) {
|
|
2113
2173
|
const window = windowLimit === void 0 ? void 0 : Math.max(1, Math.trunc(windowLimit));
|
|
@@ -2141,8 +2201,8 @@ function createGiteaTracker(deps) {
|
|
|
2141
2201
|
fetchedAt: deps.now(),
|
|
2142
2202
|
loaded: tickets.length,
|
|
2143
2203
|
total: Math.max(issues.total ?? tickets.length, tickets.length),
|
|
2144
|
-
// Gitea
|
|
2145
|
-
hierarchy: "
|
|
2204
|
+
// Gitea 没有原生子工单;父级来自子票正文首行的 `Part of #<n>` 约定。
|
|
2205
|
+
hierarchy: "convention",
|
|
2146
2206
|
tickets,
|
|
2147
2207
|
viewer,
|
|
2148
2208
|
...window === void 0 ? {} : { windowLimit: window }
|
|
@@ -2201,7 +2261,7 @@ async function readGiteaChanges(deps, workspaceRoot, pageSize, since, concurrenc
|
|
|
2201
2261
|
}));
|
|
2202
2262
|
return {
|
|
2203
2263
|
tickets,
|
|
2204
|
-
hierarchy: "
|
|
2264
|
+
hierarchy: "convention",
|
|
2205
2265
|
truncated: issues.truncated,
|
|
2206
2266
|
total,
|
|
2207
2267
|
...viewer === void 0 ? {} : { viewer }
|
|
@@ -2600,7 +2660,7 @@ function parseIssueNode(value, index, repository) {
|
|
|
2600
2660
|
const state = readState6(value.state, number);
|
|
2601
2661
|
const closedAt = readClosedAt3(value.closedAt, number);
|
|
2602
2662
|
const url = readWebUrl(value.url);
|
|
2603
|
-
const parent =
|
|
2663
|
+
const parent = readParent2(value.parent, number, repository);
|
|
2604
2664
|
return {
|
|
2605
2665
|
ref: `#${String(number)}`,
|
|
2606
2666
|
number,
|
|
@@ -2617,7 +2677,7 @@ function parseIssueNode(value, index, repository) {
|
|
|
2617
2677
|
...parent === void 0 ? {} : { parent }
|
|
2618
2678
|
};
|
|
2619
2679
|
}
|
|
2620
|
-
function
|
|
2680
|
+
function readParent2(value, number, repository) {
|
|
2621
2681
|
if (value === void 0 || value === null) return void 0;
|
|
2622
2682
|
if (!isRecord(value)) throw invalid3(`\u7B2C ${String(number)} \u5F20\u7968\u7684\u7236\u7968\u4E0D\u662F\u5BF9\u8C61`);
|
|
2623
2683
|
const parentNumber = value.number;
|
|
@@ -3259,7 +3319,7 @@ function parseWorkItemHierarchy(output) {
|
|
|
3259
3319
|
for (const node of nodes) {
|
|
3260
3320
|
if (!isRecord(node)) throw invalid4("\u5DE5\u4F5C\u9879\u5C42\u7EA7\u8282\u70B9\u4E0D\u662F\u5BF9\u8C61");
|
|
3261
3321
|
const iid = readIid2(node.iid);
|
|
3262
|
-
const parent =
|
|
3322
|
+
const parent = readParent3(node.widgets);
|
|
3263
3323
|
if (parent !== void 0) parents.set(iid, parent);
|
|
3264
3324
|
}
|
|
3265
3325
|
return parents;
|
|
@@ -3287,7 +3347,7 @@ function hierarchyQuery(batch) {
|
|
|
3287
3347
|
const iids = batch.map((iid) => `"${String(iid)}"`).join(", ");
|
|
3288
3348
|
return `query ($project: ID!) { project(fullPath: $project) { workItems(iids: [${iids}], first: ${String(batch.length)}) { nodes { iid widgets { type ... on WorkItemWidgetHierarchy { parent { iid workItemType { name } } } } } } } }`;
|
|
3289
3349
|
}
|
|
3290
|
-
function
|
|
3350
|
+
function readParent3(value) {
|
|
3291
3351
|
if (!Array.isArray(value)) return void 0;
|
|
3292
3352
|
for (const widget of value) {
|
|
3293
3353
|
if (!isRecord(widget)) continue;
|
package/package.json
CHANGED
|
@@ -19,7 +19,9 @@ Only read issue endpoints. `tea issues list --kind issues` and `type=issues` kee
|
|
|
19
19
|
|
|
20
20
|
## Parent and child tickets
|
|
21
21
|
|
|
22
|
-
Gitea has no sub-issues.
|
|
22
|
+
Gitea has no sub-issues. Make `Part of #<parent>` the **first non-empty line** of the child body, alone on that line, and register the child in the parent body's task list as `- [ ] #<child>`.
|
|
23
|
+
|
|
24
|
+
The task panel reads the parent only from that first line. A `Part of` line further down, inside a quote or heading, with extra text, or pointing at another repository is not treated as a parent. Keep `Blocked by:` lines below it; blocking never implies a parent.
|
|
23
25
|
|
|
24
26
|
## Blocking
|
|
25
27
|
|
|
@@ -29,7 +31,7 @@ Gitea's **native issue dependencies** are canonical and visible in the web UI. `
|
|
|
29
31
|
- **Add a blocker**: `tea api --method POST /repos/{owner}/{repo}/issues/<child>/dependencies -F index=<blocker>`.
|
|
30
32
|
- **Remove a blocker**: `tea api --method DELETE /repos/{owner}/{repo}/issues/<child>/dependencies -F index=<blocker>`.
|
|
31
33
|
|
|
32
|
-
The instance or the repo can disable issue dependencies; the API then answers 404. In that case put `Blocked by: #<n>, #<n>` at the top of the child body and use that line to judge blocking.
|
|
34
|
+
The instance or the repo can disable issue dependencies; the API then answers 404. In that case put `Blocked by: #<n>, #<n>` at the top of the child body (right after the `Part of` line when there is one) and use that line to judge blocking.
|
|
33
35
|
|
|
34
36
|
## Triage labels
|
|
35
37
|
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
## 父子关系
|
|
21
21
|
|
|
22
|
-
Gitea 没有子 issue
|
|
22
|
+
Gitea 没有子 issue。子票正文的**第一个非空行**单独写 `Part of #<父票>`,并在父票正文的任务列表里登记子票:`- [ ] #<子票>`。
|
|
23
|
+
|
|
24
|
+
任务面板只从这一行读父级。写在正文后面、放在引用块或标题里、带多余文字或指向其他仓库的 `Part of` 都不算父级。`Blocked by:` 行写在它下面;阻塞关系不代表父子。
|
|
23
25
|
|
|
24
26
|
## 阻塞
|
|
25
27
|
|
|
@@ -29,7 +31,7 @@ Gitea 原生的 issue 依赖是规范的、网页上也可见的表示。`tea`
|
|
|
29
31
|
- **加阻塞关系**:`tea api --method POST /repos/{owner}/{repo}/issues/<子票>/dependencies -F index=<阻塞票>`。
|
|
30
32
|
- **删阻塞关系**:`tea api --method DELETE /repos/{owner}/{repo}/issues/<子票>/dependencies -F index=<阻塞票>`。
|
|
31
33
|
|
|
32
|
-
实例或仓库可以关闭 issue 依赖功能,此时接口返回 404。这种情况下把 `Blocked by: #<n>, #<n>`
|
|
34
|
+
实例或仓库可以关闭 issue 依赖功能,此时接口返回 404。这种情况下把 `Blocked by: #<n>, #<n>` 写在子票正文顶部(有 `Part of` 行时紧跟在它后面),改用这一行判断阻塞。
|
|
33
35
|
|
|
34
36
|
## 分诊标签
|
|
35
37
|
|