Commit dfeb2ebc97f for woocommerce
commit dfeb2ebc97fd9e2e4cfbcc42fffe324df1d56d47
Author: Jorge A. Torres <jorge.torres@automattic.com>
Date: Wed Jul 15 22:29:51 2026 +0100
Avoid cherry-pick conflicts when deleting compiled changelog files (#66580)
diff --git a/tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts b/tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts
index ca58b65ffd3..c4159848361 100644
--- a/tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts
+++ b/tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts
@@ -5,7 +5,7 @@ import simpleGit from 'simple-git';
import { execSync } from 'child_process';
import { readFile, writeFile } from 'fs/promises';
import path from 'path';
-import { readFileSync } from 'fs';
+import { existsSync, readFileSync } from 'fs';
/**
* Internal dependencies
@@ -382,21 +382,51 @@ export const updateBranchChangelog = async (
milestone = `${ m[ 1 ] }.0`;
}
- try {
- await git.raw( [ 'cherry-pick', deletionCommitHash ] );
- } catch ( e ) {
- if (
- e.message.includes( 'nothing to commit, working tree clean' )
- ) {
- Logger.notice(
- 'Cherry-pick resulted in no changes, continuing without error.'
- );
- // No need to skip, just continue
- } else {
- throw e; // Re-throw if it's a different error
- }
+ // Delete by name instead of cherry-picking deletionCommitHash: cherry-pick conflicts
+ // if a file's content drifted independently on this branch (e.g. a formatting pass).
+ const changelogFiles = (
+ await git.raw( [
+ 'diff-tree',
+ '--no-commit-id',
+ '--name-only',
+ '-z',
+ '-r',
+ '--diff-filter=D',
+ deletionCommitHash,
+ ] )
+ )
+ .split( '\0' )
+ .map( ( file ) => file.trim() )
+ .filter( Boolean );
+
+ const filesToDelete = changelogFiles.filter( ( file ) =>
+ existsSync( path.join( tmpRepoPath, file ) )
+ );
+
+ const missingFiles = changelogFiles.filter(
+ ( file ) => ! filesToDelete.includes( file )
+ );
+
+ if ( missingFiles.length > 0 ) {
+ Logger.warn(
+ `${
+ missingFiles.length
+ } of the ${ version } changelog files were not found on ${ releaseBranch } by name (possibly renamed or already removed): ${ missingFiles.join(
+ ', '
+ ) }`
+ );
}
+ if ( filesToDelete.length === 0 ) {
+ Logger.notice(
+ `None of the ${ version } changelog files exist on ${ releaseBranch }, skipping.`
+ );
+ return -1;
+ }
+
+ await git.rm( filesToDelete );
+ await git.commit( `Delete changelog files from ${ version } release` );
+
await git.push( 'origin', branch, [ '--force' ] );
Logger.notice( `Creating PR for ${ branch }` );
const pullRequest = await createPullRequest( {