Reduce rush changelog to a single commit (#4387)
This commit is contained in:
Родитель
bf20880038
Коммит
16e30bcd11
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type": "none",
|
||||
"area": "improvement",
|
||||
"workstream": "",
|
||||
"comment": "Reduce rush changelog to a single commit",
|
||||
"packageName": "@azure/communication-react",
|
||||
"email": "2684369+JamesBurnside@users.noreply.github.com",
|
||||
"dependentChangeType": "none"
|
||||
}
|
|
@ -35,18 +35,24 @@ async function main() {
|
|||
// This is intentional as it gives the developer the control on when to create changefiles
|
||||
// for the entire package (irrespective of which packlet contains the changes).
|
||||
'-p', '@azure/communication-react',
|
||||
'--no-commit',
|
||||
...args
|
||||
];
|
||||
await exec(cmd.join(' '));
|
||||
await duplicateChangeFile();
|
||||
await adjustAndCommitChangeFile();
|
||||
}
|
||||
|
||||
async function duplicateChangeFile() {
|
||||
const gitLogStdout = await exec_output(`git log -1 --name-status`);
|
||||
const newChangeFilesFilenames = parseNewChangeFiles(gitLogStdout);
|
||||
/**
|
||||
* Decide if the change file needs to be duplicated, or moved to the change-beta directory.
|
||||
* If the change file is of type "none", it is not duplicated as it is not relevant for changelogs.
|
||||
* If the change file is of type "prerelease", it is only relevant for beta changelogs, so it is moved to the change-beta directory.
|
||||
* If the change file is of type "patch", "minor" or "major", it is duplicated to the change-beta directory as it is relevant for both stable and beta changelogs.
|
||||
*/
|
||||
async function adjustAndCommitChangeFile() {
|
||||
const stagedGitFiles = await exec_output(`git diff --name-only --cached`);
|
||||
const newChangeFilesFilenames = parseNewChangeFiles(stagedGitFiles);
|
||||
if (newChangeFilesFilenames.length === 0) {
|
||||
console.log('No new change files detected. Nothing to duplicate.');
|
||||
return;
|
||||
throw new Error('No new change files created by Beachball detected.');
|
||||
} else if (newChangeFilesFilenames.length > 1) {
|
||||
throw new Error(`Expected only one change file, but found ${newChangeFilesFilenames.length} change files`);
|
||||
}
|
||||
|
@ -60,7 +66,6 @@ async function duplicateChangeFile() {
|
|||
console.log(`Duplicating ${filepath} change files into ${CHANGE_DIR_BETA}`);
|
||||
fs.copyFileSync(filepath, path.join(CHANGE_DIR_BETA, changeFilename));
|
||||
await exec(`git add ${CHANGE_DIR_BETA}`);
|
||||
await exec(`git commit -m 'Duplicate change files for beta release'`);
|
||||
}
|
||||
|
||||
// if the type is prerelease, we can delete the stable changefile that was created.
|
||||
|
@ -68,8 +73,9 @@ async function duplicateChangeFile() {
|
|||
console.log(`Deleting stable change file ${filepath}`);
|
||||
fs.unlinkSync(filepath);
|
||||
await exec(`git add ${CHANGE_DIR}`);
|
||||
await exec(`git commit -m 'Remove unecessary stable change file'`);
|
||||
}
|
||||
|
||||
await exec(`git commit -m 'Change files'`);
|
||||
}
|
||||
|
||||
await main();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
const NEW_CHANGE_FILE_REGEXP = /\s*A\s*change\/(.*\.json)\s*/;
|
||||
const NEW_CHANGE_FILE_REGEXP = /\s*change\/(.*\.json)\s*/;
|
||||
|
||||
export function parseNewChangeFiles(stdout) {
|
||||
const lines = stdout.split('\n');
|
||||
|
|
Загрузка…
Ссылка в новой задаче