@@ -510,10 +510,11 @@ impl SyncGitHub {
510510 // No change needed
511511 continue ;
512512 }
513- Some ( _actual_env ) => {
513+ Some ( actual_env ) => {
514514 // Environment exists but branches differ - update it
515515 environment_diffs. push ( EnvironmentDiff :: Update (
516516 env_name. clone ( ) ,
517+ actual_env. branches . clone ( ) ,
517518 expected_env. branches . clone ( ) ,
518519 ) ) ;
519520 }
@@ -966,7 +967,7 @@ struct UpdateRepoDiff {
966967#[ derive( Debug ) ]
967968enum EnvironmentDiff {
968969 Create ( String , Vec < String > ) ,
969- Update ( String , Vec < String > ) ,
970+ Update ( String , Vec < String > , Vec < String > ) ,
970971 Delete ( String ) ,
971972}
972973
@@ -1030,8 +1031,8 @@ impl UpdateRepoDiff {
10301031 EnvironmentDiff :: Create ( name, branches) => {
10311032 sync. create_environment ( & self . org , & self . name , name, branches) ?;
10321033 }
1033- EnvironmentDiff :: Update ( name, branches ) => {
1034- sync. update_environment ( & self . org , & self . name , name, branches ) ?;
1034+ EnvironmentDiff :: Update ( name, _old_branches , new_branches ) => {
1035+ sync. update_environment ( & self . org , & self . name , name, new_branches ) ?;
10351036 }
10361037 EnvironmentDiff :: Delete ( name) => {
10371038 sync. delete_environment ( & self . org , & self . name , name) ?;
@@ -1118,10 +1119,28 @@ impl std::fmt::Display for UpdateRepoDiff {
11181119 writeln ! ( f, " Branches: {}" , branches. join( ", " ) ) ?;
11191120 }
11201121 }
1121- EnvironmentDiff :: Update ( name, branches ) => {
1122+ EnvironmentDiff :: Update ( name, old_branches , new_branches ) => {
11221123 writeln ! ( f, " 🔄 Update: {name}" ) ?;
1123- if !branches. is_empty ( ) {
1124- writeln ! ( f, " Branches: {}" , branches. join( ", " ) ) ?;
1124+ let old_set: HashSet < _ > = old_branches. iter ( ) . collect ( ) ;
1125+ let new_set: HashSet < _ > = new_branches. iter ( ) . collect ( ) ;
1126+
1127+ let mut added: Vec < _ > =
1128+ new_set. difference ( & old_set) . map ( |s| s. as_str ( ) ) . collect ( ) ;
1129+ let mut removed: Vec < _ > =
1130+ old_set. difference ( & new_set) . map ( |s| s. as_str ( ) ) . collect ( ) ;
1131+
1132+ // Sort for deterministic output
1133+ added. sort ( ) ;
1134+ removed. sort ( ) ;
1135+
1136+ if !added. is_empty ( ) {
1137+ writeln ! ( f, " Adding branches: {}" , added. join( ", " ) ) ?;
1138+ }
1139+ if !removed. is_empty ( ) {
1140+ writeln ! ( f, " Removing branches: {}" , removed. join( ", " ) ) ?;
1141+ }
1142+ if added. is_empty ( ) && removed. is_empty ( ) {
1143+ writeln ! ( f, " No branch changes" ) ?;
11251144 }
11261145 }
11271146 EnvironmentDiff :: Delete ( name) => writeln ! ( f, " ❌ Delete: {name}" ) ?,
0 commit comments