in vsts/src/utils.ts [213:246]
async function getPrSha(): Promise<string> {
if (process.env.QODANA_PR_SHA) {
return process.env.QODANA_PR_SHA
}
const {sourceBranch, targetBranch} = getSourceAndTargetBranches()
if (sourceBranch && targetBranch) {
try {
await git(['fetch', 'origin'], true)
const output = await gitOutput(
['merge-base', 'origin/' + sourceBranch, 'origin/' + targetBranch],
false,
{
ignoreReturnCode: true
}
)
if (output.exitCode === 0) {
return output.stdout.trim()
}
} catch (error) {
const message = `Failed to get PR SHA for source branch ${sourceBranch} and target branch ${targetBranch}.
The analysis would be performed with disabled prMode.
Cause:
${(error as Error).message}
To enable prMode, consider adding "fetchDepth: 0".`
tl.error(message)
return ''
}
}
return ''
}