in eng/tools/sdk-suppressions/src/updateSdkSuppressionsLabel.ts [29:71]
export async function getSdkSuppressionsSdkNames(
prChangeFiles: string,
baseCommitHash: string,
headCommitHash: string
): Promise<SdkName[]> {
console.log(`Will compare base commit: ${baseCommitHash} and head commit: ${headCommitHash} to get different SDK.`);
const filesChangedPaths = prChangeFiles.split(" ");
console.log(`The pr origin changed files: ${filesChangedPaths.join(", ")}`);
let suppressionFileList = filterSuppressionList(filesChangedPaths);
console.log(`Will compare sdk-suppression.yaml files: ${suppressionFileList.join(", ")}`);
let sdkNameList: SdkName[] = [];
if (suppressionFileList.length > 0) {
for (const suppressionFile of suppressionFileList) {
let baseSuppressionContent = await getSdkSuppressionsFileContent(baseCommitHash, suppressionFile);
const headSuppressionContent = await getSdkSuppressionsFileContent(headCommitHash, suppressionFile);
// if the head suppression file is present but anything is wrong like schema error with it return
const validateSdkSuppressionsFileResult =
validateSdkSuppressionsFile(headSuppressionContent).result;
if (!validateSdkSuppressionsFileResult) {
return [];
}
// if base suppression file does not exist, set it to an empty object but has correct schema
if (!baseSuppressionContent) {
baseSuppressionContent = { suppressions: {} };
}
console.log(
`updateSdkSuppressionsLabels: Will compare base suppressions content:\n ` +
`${JSON.stringify(baseSuppressionContent)}\n ` +
`and head suppressions content:\n ` +
`${JSON.stringify(headSuppressionContent)} to get different SDK.`,
);
sdkNameList = getSdkNamesWithChangedSuppressions(
headSuppressionContent as SdkSuppressionsYml,
baseSuppressionContent as SdkSuppressionsYml,
);
}
}
return [...new Set(sdkNameList)];
}