@@ -3865,36 +3865,33 @@ async function getChangesOnHead() {
3865
3865
return parseGitDiffOutput(output);
3866
3866
}
3867
3867
exports.getChangesOnHead = getChangesOnHead;
3868
- async function getChangesSinceMergeBase(baseRef, ref, initialFetchDepth) {
3868
+ async function getChangesSinceMergeBase(base, ref, initialFetchDepth) {
3869
+ const baseRef = `remotes/origin/${base}`;
3869
3870
async function hasMergeBase() {
3870
3871
return (await exec_1.default('git', ['merge-base', baseRef, ref], { ignoreReturnCode: true })).code === 0;
3871
3872
}
3872
3873
let noMergeBase = false;
3873
3874
core.startGroup(`Searching for merge-base ${baseRef}...${ref}`);
3874
3875
try {
3875
- let init = true;
3876
- let lastCommitCount = await getCommitCount();
3877
- let depth = Math.max(lastCommitCount * 2, initialFetchDepth);
3878
- while (!(await hasMergeBase())) {
3879
- if (init) {
3880
- await exec_1.default('git', ['fetch', `--depth=${depth}`, 'origin', `${baseRef}:${baseRef}`, `${ref}`]);
3881
- init = false;
3882
- }
3883
- else {
3884
- await exec_1.default('git', ['fetch', `--deepen=${depth}`, 'origin', baseRef, ref]);
3885
- }
3886
- const commitCount = await getCommitCount();
3887
- if (commitCount === lastCommitCount) {
3888
- core.info('No more commits were fetched');
3889
- core.info('Last attempt will be to fetch full history');
3890
- await exec_1.default('git', ['fetch', '--unshallow']);
3891
- if (!(await hasMergeBase())) {
3892
- noMergeBase = true;
3876
+ if (!(await hasMergeBase())) {
3877
+ await exec_1.default('git', ['fetch', `--depth=${initialFetchDepth}`, 'origin', base, ref]);
3878
+ let depth = initialFetchDepth;
3879
+ let lastCommitCount = await getCommitCount();
3880
+ while (!(await hasMergeBase())) {
3881
+ depth = Math.min(depth * 2, Number.MAX_SAFE_INTEGER);
3882
+ await exec_1.default('git', ['fetch', `--deepen=${depth}`, 'origin', base, ref]);
3883
+ const commitCount = await getCommitCount();
3884
+ if (commitCount === lastCommitCount) {
3885
+ core.info('No more commits were fetched');
3886
+ core.info('Last attempt will be to fetch full history');
3887
+ await exec_1.default('git', ['fetch']);
3888
+ if (!(await hasMergeBase())) {
3889
+ noMergeBase = true;
3890
+ }
3891
+ break;
3893
3892
}
3894
- break ;
3893
+ lastCommitCount = commitCount ;
3895
3894
}
3896
- depth = Math.min(depth * 2, Number.MAX_SAFE_INTEGER);
3897
- lastCommitCount = commitCount;
3898
3895
}
3899
3896
}
3900
3897
finally {
0 commit comments