@@ -486,6 +486,7 @@ function validateReleaseSync({
486486 headChangesets,
487487 releaseOutputs,
488488 headOutputs,
489+ releaseRenames = new Set ( ) ,
489490 cutManifests = new Map ( ) ,
490491 baseManifests = new Map ( ) ,
491492 releaseManifests = new Map ( ) ,
@@ -495,26 +496,41 @@ function validateReleaseSync({
495496 const planned = new Set ( plan . changesets . map ( entry => entry . path ) ) ;
496497 for ( const entry of entries ) {
497498 const [ status , ...files ] = entry . split ( '\t' ) ;
498- if ( ! status || files . length !== 1 || ! files [ 0 ] ) {
499+ const isRename = status ?. startsWith ( 'R' ) ;
500+ const expectedPaths = isRename ? 2 : 1 ;
501+ if (
502+ ! status ||
503+ files . length !== expectedPaths ||
504+ files . some ( file => ! file )
505+ ) {
499506 errors . push ( `invalid sync diff entry: ${ entry } ` ) ;
500507 continue ;
501508 }
502- const file = files [ 0 ] ;
503- if ( file . startsWith ( '.changeset/' ) ) {
504- if ( status !== 'D' || ! planned . has ( file ) )
505- errors . push ( `release sync may only delete frozen Changesets: ${ file } ` ) ;
506- } else if ( isPackageManifestPath ( file ) ) {
507- if ( ! releaseManifests . has ( file ) )
508- errors . push (
509- `release sync changed an unplanned package manifest: ${ file } ` ,
510- ) ;
511- } else if (
512- ! isReleaseOutputPath ( file ) &&
513- ! / ^ \. g i t h u b \/ p a g e s \/ a s s e t s \/ (?: m a n i f e s t \. j s o n | r e s e t \. c s s | a s t r y x \. c s s | t h e m e \. c s s ) $ / . test (
514- file ,
515- )
516- ) {
517- errors . push ( `release sync contains a non-bookkeeping path: ${ file } ` ) ;
509+ if ( isRename && ! releaseRenames . has ( files . join ( '\t' ) ) ) {
510+ errors . push (
511+ `release sync rename does not match published branch: ${ files . join ( ' -> ' ) } ` ,
512+ ) ;
513+ continue ;
514+ }
515+ for ( const file of files ) {
516+ if ( file . startsWith ( '.changeset/' ) ) {
517+ if ( status !== 'D' || ! planned . has ( file ) )
518+ errors . push (
519+ `release sync may only delete frozen Changesets: ${ file } ` ,
520+ ) ;
521+ } else if ( isPackageManifestPath ( file ) ) {
522+ if ( ! releaseManifests . has ( file ) )
523+ errors . push (
524+ `release sync changed an unplanned package manifest: ${ file } ` ,
525+ ) ;
526+ } else if (
527+ ! isReleaseOutputPath ( file ) &&
528+ ! / ^ \. g i t h u b \/ p a g e s \/ a s s e t s \/ (?: m a n i f e s t \. j s o n | r e s e t \. c s s | a s t r y x \. c s s | t h e m e \. c s s ) $ / . test (
529+ file ,
530+ )
531+ ) {
532+ errors . push ( `release sync contains a non-bookkeeping path: ${ file } ` ) ;
533+ }
518534 }
519535 }
520536 for ( const file of planned ) {
@@ -717,6 +733,23 @@ function main() {
717733 base ,
718734 'HEAD' ,
719735 ] ) ;
736+ const releaseDiff = git ( root , [
737+ 'diff' ,
738+ '--name-status' ,
739+ '--find-renames' ,
740+ plan . cutSha ,
741+ releaseRef ,
742+ ] ) ;
743+ const releaseRenames = new Set (
744+ releaseDiff
745+ . split ( '\n' )
746+ . filter ( Boolean )
747+ . map ( entry => entry . split ( '\t' ) )
748+ . filter (
749+ ( [ status , ...files ] ) => status ?. startsWith ( 'R' ) && files . length === 2 ,
750+ )
751+ . map ( ( [ , ...files ] ) => files . join ( '\t' ) ) ,
752+ ) ;
720753 const releaseOutputs = releaseOutputMapAtRef ( root , plan , releaseRef ) ;
721754 const releaseManifestFiles = releaseOutputPathsAtRef (
722755 root ,
@@ -744,6 +777,7 @@ function main() {
744777 ) ,
745778 releaseOutputs,
746779 headOutputs : currentOutputMap ( root , releaseOutputs . keys ( ) ) ,
780+ releaseRenames,
747781 cutManifests,
748782 baseManifests,
749783 releaseManifests,
0 commit comments