ework-web 0.10.97 → 0.10.98
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/package.json +1 -1
- package/src/upstream-sync.ts +15 -2
package/package.json
CHANGED
package/src/upstream-sync.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getIssueByUpstreamNumber,
|
|
7
7
|
getCommentByUpstreamId,
|
|
8
8
|
createIssue,
|
|
9
|
+
ensureUser,
|
|
9
10
|
postComment,
|
|
10
11
|
editIssue,
|
|
11
12
|
updateUpstreamSyncState,
|
|
@@ -43,6 +44,12 @@ export interface UpstreamSyncPollResult {
|
|
|
43
44
|
|
|
44
45
|
const GITEA_COMMENT_ISSUE_RE = /\/issues\/(\d+)$/;
|
|
45
46
|
|
|
47
|
+
// GitHub CI/actions identities end in [bot]; their comments must not wake
|
|
48
|
+
// the engine, so they are imported as bot-kind users.
|
|
49
|
+
function fromGithubBot(login: string | undefined): boolean {
|
|
50
|
+
return typeof login === "string" && /\[bot\]$/i.test(login.trim());
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
function upstreamIssueNumberFromComment(gc: GiteaComment): number | null {
|
|
47
54
|
const m = (gc.issue_url ?? "").match(GITEA_COMMENT_ISSUE_RE);
|
|
48
55
|
return m ? Number(m[1]) : null;
|
|
@@ -103,6 +110,7 @@ export class UpstreamSync {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
private async importIssue(gi: GiteaIssue, emit: boolean): Promise<void> {
|
|
113
|
+
await ensureUser(gi.user?.login ?? "upstream", fromGithubBot(gi.user?.login) ? "bot" : "human");
|
|
106
114
|
await createIssue(
|
|
107
115
|
this.project.id,
|
|
108
116
|
(gi.pull_request ? "[PR] " : "") + (gi.title || `#${gi.number}`),
|
|
@@ -143,7 +151,10 @@ export class UpstreamSync {
|
|
|
143
151
|
if (await getCommentByUpstreamId(gc.id)) continue;
|
|
144
152
|
// write-back comments carry this marker; importing them would duplicate locally
|
|
145
153
|
if ((gc.body ?? "").includes("<!-- ework-mirror -->")) continue;
|
|
146
|
-
const
|
|
154
|
+
const gcAuthor = gc.user?.login ?? "upstream";
|
|
155
|
+
// ensure the kind before postComment's internal user creation runs
|
|
156
|
+
await ensureUser(gcAuthor, fromGithubBot(gcAuthor) ? "bot" : "human");
|
|
157
|
+
const row = await postComment(local.id, gc.body ?? "", gcAuthor, {
|
|
147
158
|
createdAt: gc.created_at,
|
|
148
159
|
updatedAt: gc.updated_at,
|
|
149
160
|
upstreamCommentId: gc.id,
|
|
@@ -221,7 +232,9 @@ export class UpstreamSync {
|
|
|
221
232
|
if (!upstreamNumber) continue;
|
|
222
233
|
const local = await getIssueByUpstreamNumber(this.project.id, upstreamNumber);
|
|
223
234
|
if (!local) continue;
|
|
224
|
-
const
|
|
235
|
+
const gcAuthor = gc.user?.login ?? "upstream";
|
|
236
|
+
await ensureUser(gcAuthor, fromGithubBot(gcAuthor) ? "bot" : "human");
|
|
237
|
+
const row = await postComment(local.id, gc.body ?? "", gcAuthor, {
|
|
225
238
|
createdAt: gc.created_at,
|
|
226
239
|
updatedAt: gc.updated_at,
|
|
227
240
|
upstreamCommentId: gc.id,
|