Skip to content

Commit 166c659

Browse files
committed
Change repository sync order to handle archiving
1 parent 28d1582 commit 166c659

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sync-team/src/github/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,16 @@ impl UpdateRepoDiff {
732732
return Ok(());
733733
}
734734

735-
if self.settings_diff.0 != self.settings_diff.1 {
735+
// If we're unarchiving, we have to unarchive first and *then* modify other properties
736+
// of the repository. On the other hand, if we're achiving, we need to perform
737+
// the archiving *last* (otherwise permissions and branch protections cannot be modified)
738+
// anymore. If we're not changing the archival status, the order doesn't really matter.
739+
let is_unarchive = self.settings_diff.0.archived && !self.settings_diff.1.archived;
740+
741+
if is_unarchive {
736742
sync.edit_repo(&self.org, &self.name, &self.settings_diff.1)?;
737743
}
744+
738745
for permission in &self.permission_diffs {
739746
permission.apply(sync, &self.org, &self.name)?;
740747
}
@@ -743,6 +750,10 @@ impl UpdateRepoDiff {
743750
branch_protection.apply(sync, &self.org, &self.name, &self.repo_node_id)?;
744751
}
745752

753+
if !is_unarchive && self.settings_diff.0 != self.settings_diff.1 {
754+
sync.edit_repo(&self.org, &self.name, &self.settings_diff.1)?;
755+
}
756+
746757
Ok(())
747758
}
748759
}

0 commit comments

Comments
 (0)