Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/create-release-branch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bump `@metamask/auto-changelog` from `^7.0.0` to `^7.0.1` ([#129](https://github.com/MetaMask/release-tools/pull/129))

### Fixed

- Fix the "Initialize Release" commit failing with "nothing to commit" when the changelogs are already up to date ([#142](https://github.com/MetaMask/release-tools/pull/142))

## [4.2.3]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ describe('monorepo-workflow-operations', () => {
1,
projectDirectoryPath,
`Initialize Release ${releaseVersion}`,
{ allowEmpty: true },
);
expect(commitAllChangesSpy).toHaveBeenNthCalledWith(
2,
Expand Down Expand Up @@ -621,6 +622,7 @@ describe('monorepo-workflow-operations', () => {
expect(commitAllChangesSpy).toHaveBeenCalledWith(
projectDirectoryPath,
'Initialize Release 2.0.0',
{ allowEmpty: true },
);

expect(commitAllChangesSpy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -718,6 +720,7 @@ describe('monorepo-workflow-operations', () => {
expect(commitAllChangesSpy).toHaveBeenCalledWith(
projectDirectoryPath,
'Initialize Release 2.0.0',
{ allowEmpty: true },
);
expect(commitAllChangesSpy).not.toHaveBeenCalledWith(
projectDirectoryPath,
Expand Down Expand Up @@ -1160,6 +1163,7 @@ describe('monorepo-workflow-operations', () => {
expect(commitAllChangesSpy).toHaveBeenCalledWith(
projectDirectoryPath,
'Initialize Release 2.0.0',
{ allowEmpty: true },
);

expect(commitAllChangesSpy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -1431,6 +1435,7 @@ describe('monorepo-workflow-operations', () => {
expect(commitAllChangesSpy).toHaveBeenCalledWith(
projectDirectoryPath,
'Initialize Release 2.0.0',
{ allowEmpty: true },
);

expect(commitAllChangesSpy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -1974,6 +1979,7 @@ describe('monorepo-workflow-operations', () => {
expect(commitAllChangesSpy).toHaveBeenCalledWith(
projectDirectoryPath,
'Initialize Release 2.0.0',
{ allowEmpty: true },
);

expect(commitAllChangesSpy).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export async function followMonorepoWorkflow({
await commitAllChanges(
project.directoryPath,
`Initialize Release ${newReleaseVersion}`,
// Changelogs may already be up to date, in which case there is nothing
// to commit.
{ allowEmpty: true },
);
}

Expand Down
16 changes: 16 additions & 0 deletions packages/create-release-branch/src/repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ describe('repo', () => {
{ cwd: '/path/to/project' },
);
});

it('passes `--allow-empty` when `allowEmpty` is true', async () => {
const getStdoutFromCommandSpy = vi.spyOn(
miscUtils,
'getStdoutFromCommand',
);
await commitAllChanges('/path/to/project', 'Release 1.0.0', {
allowEmpty: true,
});

expect(getStdoutFromCommandSpy).toHaveBeenCalledWith(
'git',
['commit', '-m', 'Release 1.0.0', '--allow-empty'],
{ cwd: '/path/to/project' },
);
});
});

describe('getTagNames', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/create-release-branch/src/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,21 @@ async function getFilesChangedSince(
*
* @param repositoryDirectoryPath - The file system path to the git repository where changes are to be committed.
* @param commitMessage - The message to be used for the git commit.
* @param options - The options.
* @param options.allowEmpty - Whether to create the commit even if there are no
* changes to commit.
* @throws If any git command fails to execute.
*/
export async function commitAllChanges(
repositoryDirectoryPath: string,
commitMessage: string,
{ allowEmpty = false }: { allowEmpty?: boolean } = {},
): Promise<void> {
await getStdoutFromGitCommandWithin(repositoryDirectoryPath, 'add', ['-A']);
await getStdoutFromGitCommandWithin(repositoryDirectoryPath, 'commit', [
'-m',
commitMessage,
...(allowEmpty ? ['--allow-empty'] : []),
]);
}

Expand Down
Loading