mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 09:39:25 +00:00
fix(ci): avoid dependency warnings from unrelated main updates (#156040)
This commit is contained in:
parent
469b35a80b
commit
e6bd12b4cd
3 changed files with 96 additions and 2 deletions
|
|
@ -437,14 +437,31 @@ async function readBase64FileAtRef(api, { owner, repo, path, ref }) {
|
|||
async function collectDependencyManifestChanges(api, { owner, repo, pullRequest, files }) {
|
||||
const { isDependencyManifest } = loadSecurityReviewPolicy();
|
||||
const changes = [];
|
||||
let mergeBaseSha;
|
||||
for (const file of files) {
|
||||
const basePath = file.previous_filename ?? file.filename;
|
||||
const headPath = file.filename;
|
||||
if (!isDependencyManifest(basePath) && !isDependencyManifest(headPath)) {
|
||||
continue;
|
||||
}
|
||||
if (!mergeBaseSha) {
|
||||
// Match the PR diff: unrelated dependency updates on the target branch
|
||||
// must neither invent nor hide manifest changes introduced by this PR.
|
||||
// Page two omits file patches; only the comparison metadata is needed.
|
||||
const baseSha = pullRequest.base?.sha;
|
||||
const comparison = await api.request(
|
||||
`/repos/${owner}/${repo}/compare/${baseSha}...${pullRequest.head?.sha}?per_page=1&page=2`,
|
||||
);
|
||||
if (
|
||||
comparison?.base_commit?.sha !== baseSha ||
|
||||
!/^[a-f0-9]{40}$/u.test(comparison?.merge_base_commit?.sha ?? "")
|
||||
) {
|
||||
throw new GitHubDiffDataError("GitHub returned an invalid dependency manifest merge base.");
|
||||
}
|
||||
mergeBaseSha = comparison.merge_base_commit.sha;
|
||||
}
|
||||
const baseManifest = isDependencyManifest(basePath)
|
||||
? await readJsonFileAtRef(api, { owner, repo, path: basePath, ref: pullRequest.base?.sha })
|
||||
? await readJsonFileAtRef(api, { owner, repo, path: basePath, ref: mergeBaseSha })
|
||||
: null;
|
||||
const headManifest = isDependencyManifest(headPath)
|
||||
? await readJsonFileAtRef(api, { owner, repo, path: headPath, ref: pullRequest.head?.sha })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue