mirror of
https://github.com/dorny/paths-filter.git
synced 2025-06-24 03:18:02 +02:00
Refactor getChangesSinceMergeBase() code
This commit is contained in:
36
dist/index.js
vendored
36
dist/index.js
vendored
@ -3873,29 +3873,25 @@ async function getChangesSinceMergeBase(base, initialFetchDepth) {
|
||||
let noMergeBase = false;
|
||||
core.startGroup(`Searching for merge-base ${baseRef}...${exports.HEAD}`);
|
||||
try {
|
||||
let init = true;
|
||||
let lastCommitCount = await getCommitCount();
|
||||
let depth = Math.max(lastCommitCount * 2, initialFetchDepth);
|
||||
while (!(await hasMergeBase())) {
|
||||
if (init) {
|
||||
await exec_1.default('git', ['fetch', `--depth=${depth}`, 'origin', base, exports.HEAD]);
|
||||
init = false;
|
||||
}
|
||||
else {
|
||||
if (!(await hasMergeBase())) {
|
||||
await exec_1.default('git', ['fetch', `--depth=${initialFetchDepth}`, 'origin', base, exports.HEAD]);
|
||||
let depth = initialFetchDepth;
|
||||
let lastCommitCount = await getCommitCount();
|
||||
while (!(await hasMergeBase())) {
|
||||
depth = Math.min(depth * 2, Number.MAX_SAFE_INTEGER);
|
||||
await exec_1.default('git', ['fetch', `--deepen=${depth}`, 'origin', base, exports.HEAD]);
|
||||
}
|
||||
const commitCount = await getCommitCount();
|
||||
if (commitCount === lastCommitCount) {
|
||||
core.info('No more commits were fetched');
|
||||
core.info('Last attempt will be to fetch full history');
|
||||
await exec_1.default('git', ['fetch']);
|
||||
if (!(await hasMergeBase())) {
|
||||
noMergeBase = true;
|
||||
const commitCount = await getCommitCount();
|
||||
if (commitCount === lastCommitCount) {
|
||||
core.info('No more commits were fetched');
|
||||
core.info('Last attempt will be to fetch full history');
|
||||
await exec_1.default('git', ['fetch']);
|
||||
if (!(await hasMergeBase())) {
|
||||
noMergeBase = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
lastCommitCount = commitCount;
|
||||
}
|
||||
depth = Math.min(depth * 2, Number.MAX_SAFE_INTEGER);
|
||||
lastCommitCount = commitCount;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
Reference in New Issue
Block a user