refactor(bump-all-updated-packages): use tag instead of custom commit message (#36220)
Summary: Having custom commit message script is not an option for `main` branch, because we have internal tooling, which strips `[x]` tags from commit messages before merging them into `main` branch. Instead of constant commit message, we are now using a tag which will be concatenated with the commit message, which was entered via interactive commit dialog, see demo below. ## Changelog [Internal] - updated validation in bumping packages script Pull Request resolved: https://github.com/facebook/react-native/pull/36220 Test Plan: https://user-images.githubusercontent.com/28902667/220163767-015bf37b-6914-4df2-84d9-aa25fb2887d3.mov Reviewed By: cortinico Differential Revision: D43443597 Pulled By: hoxyq fbshipit-source-id: 08e5e08524a1d934fbb35529e025358d7bf3b203
This commit is contained in:
Родитель
0e30c7b853
Коммит
18b402cbd0
|
@ -9,7 +9,7 @@
|
|||
|
||||
const {spawnSync} = require('child_process');
|
||||
|
||||
const {BUMP_COMMIT_MESSAGE} = require('../constants');
|
||||
const {PUBLISH_PACKAGES_TAG} = require('../constants');
|
||||
const forEachPackage = require('../for-each-package');
|
||||
const findAndPublishAllBumpedPackages = require('../find-and-publish-all-bumped-packages');
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe('findAndPublishAllBumpedPackages', () => {
|
|||
}));
|
||||
|
||||
spawnSync.mockImplementationOnce(() => ({
|
||||
stdout: BUMP_COMMIT_MESSAGE,
|
||||
stdout: `This is my commit message\n\n${PUBLISH_PACKAGES_TAG}`,
|
||||
}));
|
||||
|
||||
expect(() => findAndPublishAllBumpedPackages()).toThrow(
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
*/
|
||||
|
||||
const chalk = require('chalk');
|
||||
const {execSync} = require('child_process');
|
||||
const inquirer = require('inquirer');
|
||||
const path = require('path');
|
||||
const {echo, exec, exit} = require('shelljs');
|
||||
const yargs = require('yargs');
|
||||
|
||||
const {BUMP_COMMIT_MESSAGE} = require('../constants');
|
||||
const {PUBLISH_PACKAGES_TAG} = require('../constants');
|
||||
const forEachPackage = require('../for-each-package');
|
||||
const checkForGitChanges = require('../check-for-git-changes');
|
||||
const bumpPackageVersion = require('./bump-package-version');
|
||||
|
@ -167,7 +168,21 @@ const main = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
exec(`git commit -a -m "${BUMP_COMMIT_MESSAGE}"`, {cwd: ROOT_LOCATION});
|
||||
// exec from shelljs currently does not support interactive input
|
||||
// https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec
|
||||
execSync('git commit -a', {cwd: ROOT_LOCATION, stdio: 'inherit'});
|
||||
|
||||
const enteredCommitMessage = exec('git log -n 1 --format=format:%B', {
|
||||
cwd: ROOT_LOCATION,
|
||||
silent: true,
|
||||
}).stdout.trim();
|
||||
const commitMessageWithTag =
|
||||
enteredCommitMessage + `\n\n${PUBLISH_PACKAGES_TAG}`;
|
||||
|
||||
exec(`git commit --amend -m "${commitMessageWithTag}"`, {
|
||||
cwd: ROOT_LOCATION,
|
||||
silent: true,
|
||||
});
|
||||
})
|
||||
.then(() => echo());
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
* @format
|
||||
*/
|
||||
|
||||
const BUMP_COMMIT_MESSAGE = '[ci][monorepo] bump package versions';
|
||||
const PUBLISH_PACKAGES_TAG = '@publish-packages-to-npm';
|
||||
|
||||
module.exports = {BUMP_COMMIT_MESSAGE};
|
||||
module.exports = {PUBLISH_PACKAGES_TAG};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
const path = require('path');
|
||||
const {spawnSync} = require('child_process');
|
||||
|
||||
const {BUMP_COMMIT_MESSAGE} = require('./constants');
|
||||
const {PUBLISH_PACKAGES_TAG} = require('./constants');
|
||||
const forEachPackage = require('./for-each-package');
|
||||
|
||||
const ROOT_LOCATION = path.join(__dirname, '..', '..');
|
||||
|
@ -79,10 +79,10 @@ const findAndPublishAllBumpedPackages = () => {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
const hasSpecificCommitMessage =
|
||||
commitMessage.startsWith(BUMP_COMMIT_MESSAGE);
|
||||
const hasSpecificPublishTag =
|
||||
commitMessage.includes(PUBLISH_PACKAGES_TAG);
|
||||
|
||||
if (!hasSpecificCommitMessage) {
|
||||
if (!hasSpecificPublishTag) {
|
||||
throw new Error(
|
||||
`Package ${packageManifest.name} was updated, but not through CI script`,
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче