Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 92c3e8a

Browse files
KobzolMark-Simulacrum
authored andcommitted
Avoid changing repository properties when the repository is archived
1 parent cf3df09 commit 92c3e8a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/github/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,30 @@ struct UpdateRepoDiff {
629629

630630
impl UpdateRepoDiff {
631631
pub(crate) fn noop(&self) -> bool {
632+
if !self.can_be_modified() {
633+
return true;
634+
}
635+
632636
self.settings_diff.0 == self.settings_diff.1
633637
&& self.permission_diffs.is_empty()
634638
&& self.branch_protection_diffs.is_empty()
635639
}
636640

641+
fn can_be_modified(&self) -> bool {
642+
// Archived repositories cannot be modified
643+
// If the repository should be archived, and we do not change its archival status,
644+
// we should not change any other properties of the repo.
645+
if self.settings_diff.1.archived && self.settings_diff.0.archived {
646+
return false;
647+
}
648+
true
649+
}
650+
637651
fn apply(&self, sync: &GitHubWrite) -> anyhow::Result<()> {
652+
if !self.can_be_modified() {
653+
return Ok(());
654+
}
655+
638656
if self.settings_diff.0 != self.settings_diff.1 {
639657
sync.edit_repo(&self.org, &self.name, &self.settings_diff.1)?;
640658
}

0 commit comments

Comments
 (0)