chore: fix notes stack updates (#41600)
* chore: fix removeSupercededStackUpdates for generating notes * add early stop for less than * Update script/release/notes/notes.js Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * clean up comparison functionality * add tests --------- Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
parent
5310b79ffb
commit
ef097b77ad
2 changed files with 67 additions and 1 deletions
|
@ -485,6 +485,24 @@ const getNotes = async (fromRef, toRef, newVersion) => {
|
||||||
return notes;
|
return notes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const compareVersions = (v1, v2) => {
|
||||||
|
const [split1, split2] = [v1.split('.'), v2.split('.')];
|
||||||
|
|
||||||
|
if (split1.length !== split2.length) {
|
||||||
|
throw new Error(`Expected version strings to have same number of sections: ${split1} and ${split2}`);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < split1.length; i++) {
|
||||||
|
const p1 = parseInt(split1[i], 10);
|
||||||
|
const p2 = parseInt(split2[i], 10);
|
||||||
|
|
||||||
|
if (p1 > p2) return 1;
|
||||||
|
else if (p1 < p2) return -1;
|
||||||
|
// Continue checking the value if this portion is equal
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
const removeSupercededStackUpdates = (commits) => {
|
const removeSupercededStackUpdates = (commits) => {
|
||||||
const updateRegex = /^Updated ([a-zA-Z.]+) to v?([\d.]+)/;
|
const updateRegex = /^Updated ([a-zA-Z.]+) to v?([\d.]+)/;
|
||||||
const notupdates = [];
|
const notupdates = [];
|
||||||
|
@ -496,8 +514,9 @@ const removeSupercededStackUpdates = (commits) => {
|
||||||
notupdates.push(commit);
|
notupdates.push(commit);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [, dep, version] = match;
|
const [, dep, version] = match;
|
||||||
if (!newest[dep] || newest[dep].version < version) {
|
if (!newest[dep] || compareVersions(version, newest[dep].version) > 0) {
|
||||||
newest[dep] = { commit, version };
|
newest[dep] = { commit, version };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,4 +211,51 @@ describe('release notes', () => {
|
||||||
expect(results.breaking[0].hash).to.equal(testCommit.sha1);
|
expect(results.breaking[0].hash).to.equal(testCommit.sha1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// test that when you have multiple stack updates only the
|
||||||
|
// latest will be kept
|
||||||
|
describe('superseding stack updates', () => {
|
||||||
|
const oldBranch = '27-x-y';
|
||||||
|
const newBranch = '28-x-y';
|
||||||
|
|
||||||
|
const version = 'v28.0.0';
|
||||||
|
|
||||||
|
it('with different major versions', async function () {
|
||||||
|
const mostRecentCommit = new Commit('9d0e6d09f0be0abbeae46dd3d66afd96d2daacaa', 'chore: bump chromium to 119.0.6043.0');
|
||||||
|
|
||||||
|
const sharedChromiumHistory = [
|
||||||
|
new Commit('029127a8b6f7c511fca4612748ad5b50e43aadaa', 'chore: bump chromium to 118.0.5993.0') // merge-base
|
||||||
|
];
|
||||||
|
const chromiumPatchUpdates = [
|
||||||
|
new Commit('d9ba26273ad3e7a34c905eccbd5dabda4eb7b402', 'chore: bump chromium to 118.0.5991.0'),
|
||||||
|
mostRecentCommit,
|
||||||
|
new Commit('d6c8ff2e7050f30dffd784915bcbd2a9f993cdb2', 'chore: bump chromium to 119.0.6029.0')
|
||||||
|
];
|
||||||
|
|
||||||
|
gitFake.setBranch(oldBranch, sharedChromiumHistory);
|
||||||
|
gitFake.setBranch(newBranch, [...sharedChromiumHistory, ...chromiumPatchUpdates]);
|
||||||
|
|
||||||
|
const results: any = await notes.get(oldBranch, newBranch, version);
|
||||||
|
expect(results.other).to.have.lengthOf(1);
|
||||||
|
expect(results.other[0].hash).to.equal(mostRecentCommit.sha1);
|
||||||
|
});
|
||||||
|
it('with different build versions', async function () {
|
||||||
|
const mostRecentCommit = new Commit('8f7a48879ef8633a76279803637cdee7f7c6cd4f', 'chore: bump chromium to 119.0.6045.0');
|
||||||
|
|
||||||
|
const sharedChromiumHistory = [
|
||||||
|
new Commit('029127a8b6f7c511fca4612748ad5b50e43aadaa', 'chore: bump chromium to 118.0.5993.0') // merge-base
|
||||||
|
];
|
||||||
|
const chromiumPatchUpdates = [
|
||||||
|
mostRecentCommit,
|
||||||
|
new Commit('9d0e6d09f0be0abbeae46dd3d66afd96d2daacaa', 'chore: bump chromium to 119.0.6043.0'),
|
||||||
|
new Commit('d6c8ff2e7050f30dffd784915bcbd2a9f993cdb2', 'chore: bump chromium to 119.0.6029.0')
|
||||||
|
];
|
||||||
|
|
||||||
|
gitFake.setBranch(oldBranch, sharedChromiumHistory);
|
||||||
|
gitFake.setBranch(newBranch, [...sharedChromiumHistory, ...chromiumPatchUpdates]);
|
||||||
|
|
||||||
|
const results: any = await notes.get(oldBranch, newBranch, version);
|
||||||
|
expect(results.other).to.have.lengthOf(1);
|
||||||
|
expect(results.other[0].hash).to.equal(mostRecentCommit.sha1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue