cwm-assistant 0.4.0 → 0.4.1
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.
|
@@ -2619,7 +2619,7 @@ var Type = type_exports2;
|
|
|
2619
2619
|
|
|
2620
2620
|
// ../../packages/contracts/src/assistant.ts
|
|
2621
2621
|
var ASSISTANT_PROTOCOL = 1;
|
|
2622
|
-
var ASSISTANT_VERSION = "0.4.
|
|
2622
|
+
var ASSISTANT_VERSION = "0.4.1";
|
|
2623
2623
|
var ASSISTANT_PORT = 46322;
|
|
2624
2624
|
|
|
2625
2625
|
// ../../packages/contracts/src/index.ts
|
|
@@ -5751,6 +5751,28 @@ async function latestComparison(cwd, branch, force) {
|
|
|
5751
5751
|
comparisonSyncs.set(key, entry);
|
|
5752
5752
|
return entry.result;
|
|
5753
5753
|
}
|
|
5754
|
+
async function branchHasChanges(cwd, branch, compareBranch) {
|
|
5755
|
+
if (!fs22.existsSync(cwd)) return true;
|
|
5756
|
+
const baseline = normalizeCommitCompareBranch(compareBranch) || "production";
|
|
5757
|
+
const target = normalizeCommitCompareBranch(branch);
|
|
5758
|
+
if (!target) return true;
|
|
5759
|
+
try {
|
|
5760
|
+
const base = await latestComparison(cwd, baseline, false);
|
|
5761
|
+
if ("unavailable" in base) return true;
|
|
5762
|
+
const candidates = ["refs/remotes/origin/" + target, "refs/heads/" + target];
|
|
5763
|
+
for (const candidate of candidates) {
|
|
5764
|
+
try {
|
|
5765
|
+
const tip = await git2(cwd, ["rev-parse", "--verify", "--end-of-options", candidate]);
|
|
5766
|
+
const ahead = Number(await git2(cwd, ["rev-list", "--count", base.commit + ".." + tip]));
|
|
5767
|
+
return ahead > 0;
|
|
5768
|
+
} catch {
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
return true;
|
|
5772
|
+
} catch {
|
|
5773
|
+
return true;
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5754
5776
|
async function readWorkspaceCommits(mount, offset = 0, refresh = false) {
|
|
5755
5777
|
const compareBranch = normalizeCommitCompareBranch(mount.commit_compare_branch);
|
|
5756
5778
|
const empty = {
|
|
@@ -5859,6 +5881,23 @@ function registerQueryRoutes(app, store) {
|
|
|
5859
5881
|
const { mount, folders } = localWorkspace(store, requestGrant(request), id);
|
|
5860
5882
|
return { ...mount, folders };
|
|
5861
5883
|
});
|
|
5884
|
+
app.post("/v1/versions/branch-activity", async (request) => {
|
|
5885
|
+
const grant = requestGrant(request);
|
|
5886
|
+
const body = request.body;
|
|
5887
|
+
if (!Array.isArray(body?.branches)) throw new Error("\u5206\u652F\u5217\u8868\u65E0\u6548");
|
|
5888
|
+
const active = [];
|
|
5889
|
+
for (const item of body.branches) {
|
|
5890
|
+
const repositoryId = String(item?.repositoryId || "");
|
|
5891
|
+
const branch = String(item?.branch || "");
|
|
5892
|
+
if (!repositoryId || !branch) continue;
|
|
5893
|
+
const path30 = store.state.repositories[scopeKey(grant.workbenchId, grant.userId, repositoryId)];
|
|
5894
|
+
const changed = await git4(
|
|
5895
|
+
() => branchHasChanges(path30 || "", branch, String(item?.compareBranch || ""))
|
|
5896
|
+
);
|
|
5897
|
+
if (changed) active.push(repositoryId + "\0" + branch);
|
|
5898
|
+
}
|
|
5899
|
+
return { active };
|
|
5900
|
+
});
|
|
5862
5901
|
app.get("/v1/workspaces/:id/repositories/:index/commits", async (request) => {
|
|
5863
5902
|
const { id, index } = request.params;
|
|
5864
5903
|
const query = request.query;
|
|
@@ -6108,6 +6147,7 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
|
|
|
6108
6147
|
fs24.mkdirSync(root, { recursive: true });
|
|
6109
6148
|
const results = [], folders = [];
|
|
6110
6149
|
const groups = [...new Set(includedMounts.map((mount) => mount.repository_id))];
|
|
6150
|
+
const emptyRepositories = /* @__PURE__ */ new Set();
|
|
6111
6151
|
log("\u5BA1\u67E5\u4ED3\u5E93\u603B\u6570\uFF1A" + groups.length);
|
|
6112
6152
|
excludedRepositories.forEach((repo) => log("\u5DF2\u6392\u9664\uFF1A" + repo.alias + "\uFF08" + repo.reason + "\uFF09"));
|
|
6113
6153
|
for (const repositoryId of groups) {
|
|
@@ -6148,13 +6188,44 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
|
|
|
6148
6188
|
if (!ref) throw new Error(repo.alias + "\uFF1A\u8FDC\u7AEF\u5206\u652F\u4E0D\u5B58\u5728\uFF1A" + clean);
|
|
6149
6189
|
return ref.sha;
|
|
6150
6190
|
};
|
|
6191
|
+
const compareName = (repo.compare_branch || "").replace(/^origin\//, "") || production;
|
|
6192
|
+
const baseSha = await resolveBranch(compareName).catch(() => "");
|
|
6193
|
+
const activeEntries = [];
|
|
6194
|
+
for (const entry of entries) {
|
|
6195
|
+
if (!baseSha) {
|
|
6196
|
+
activeEntries.push(entry);
|
|
6197
|
+
continue;
|
|
6198
|
+
}
|
|
6199
|
+
const tip = await resolveBranch(entry.branch).catch(() => "");
|
|
6200
|
+
const ahead = tip ? Number(
|
|
6201
|
+
await git3(directory, ["rev-list", "--count", baseSha + ".." + tip]).catch(() => "1")
|
|
6202
|
+
) : 1;
|
|
6203
|
+
if (ahead > 0) activeEntries.push(entry);
|
|
6204
|
+
else
|
|
6205
|
+
log(entry.alias + "\uFF1A" + entry.branch + " \u76F8\u5BF9 " + compareName + " \u65E0\u6539\u52A8\uFF0C\u4E0D\u7EB3\u5165\u5BA1\u67E5");
|
|
6206
|
+
}
|
|
6207
|
+
if (!activeEntries.length) {
|
|
6208
|
+
results.splice(results.indexOf(result2), 1);
|
|
6209
|
+
emptyRepositories.add(repositoryId);
|
|
6210
|
+
const folderIndex = folders.findIndex((folder) => folder.name === repo.alias);
|
|
6211
|
+
if (folderIndex >= 0) folders.splice(folderIndex, 1);
|
|
6212
|
+
excludedRepositories.push({
|
|
6213
|
+
repositoryId,
|
|
6214
|
+
alias: repo.alias,
|
|
6215
|
+
reason: "\u5206\u652F\u76F8\u5BF9 " + compareName + " \u65E0\u6539\u52A8"
|
|
6216
|
+
});
|
|
6217
|
+
log("\u5DF2\u6392\u9664\uFF1A" + repo.alias + "\uFF08\u5206\u652F\u76F8\u5BF9 " + compareName + " \u65E0\u6539\u52A8\uFF09");
|
|
6218
|
+
continue;
|
|
6219
|
+
}
|
|
6220
|
+
entries.length = 0;
|
|
6221
|
+
entries.push(...activeEntries);
|
|
6151
6222
|
const p = await resolveBranch(production), s = await resolveBranch(staging);
|
|
6152
6223
|
result2.refs = { production: p, staging: s };
|
|
6153
|
-
for (const branch of [...new Set(
|
|
6224
|
+
for (const branch of [...new Set(activeEntries.map((entry) => entry.branch))])
|
|
6154
6225
|
result2.branches.push({
|
|
6155
6226
|
name: branch,
|
|
6156
6227
|
sha: await resolveBranch(branch),
|
|
6157
|
-
requirementIds:
|
|
6228
|
+
requirementIds: activeEntries.filter((entry) => entry.branch === branch).map((entry) => entry.requirement_id)
|
|
6158
6229
|
});
|
|
6159
6230
|
log("\u5F00\u59CB\u5B8C\u6574\u6027\u68C0\u67E5\uFF1A" + repo.alias);
|
|
6160
6231
|
let mergeConflict = false;
|
|
@@ -6188,8 +6259,11 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
|
|
|
6188
6259
|
log(repo.alias + "\uFF1A\u68C0\u67E5\u5931\u8D25");
|
|
6189
6260
|
}
|
|
6190
6261
|
}
|
|
6262
|
+
const coveredMounts = initial.mounts.filter(
|
|
6263
|
+
(mount) => !emptyRepositories.has(mount.repository_id)
|
|
6264
|
+
);
|
|
6191
6265
|
const uncoveredRequirements = initial.requirements.filter(
|
|
6192
|
-
(requirement) => !
|
|
6266
|
+
(requirement) => !coveredMounts.some((mount) => mount.requirement_id === requirement.id)
|
|
6193
6267
|
);
|
|
6194
6268
|
const stale = false;
|
|
6195
6269
|
const result = stale ? "STALE" : results.some((repo) => ["ERROR", "CONFLICT"].includes(repo.status)) ? "BLOCKED" : uncoveredRequirements.length || results.some((repo) => repo.status === "WARN") ? "WARN" : "PASS";
|
|
@@ -6205,6 +6279,7 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
|
|
|
6205
6279
|
2
|
|
6206
6280
|
)
|
|
6207
6281
|
);
|
|
6282
|
+
if (!results.length) throw new Error("\u6240\u6709\u5173\u8054\u5206\u652F\u76F8\u5BF9\u5BF9\u6BD4\u5206\u652F\u5747\u65E0\u6539\u52A8\uFF0C\u65E0\u53EF\u5BA1\u67E5\u7684\u4ED3\u5E93");
|
|
6208
6283
|
const snapshot = {
|
|
6209
6284
|
type: "release-integrity",
|
|
6210
6285
|
formatVersion: 4,
|
|
@@ -6872,4 +6947,4 @@ async function cli(args, entry) {
|
|
|
6872
6947
|
export {
|
|
6873
6948
|
cli
|
|
6874
6949
|
};
|
|
6875
|
-
//# sourceMappingURL=cli-
|
|
6950
|
+
//# sourceMappingURL=cli-KVOOANBW.js.map
|