Added CLI command to automate team and repo archival#2420
Added CLI command to automate team and repo archival#2420Sandijigs wants to merge 1 commit intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
f71bf56 to
9335836
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
9335836 to
dfedaf1
Compare
Dry-run check results |
dfedaf1 to
f595a4d
Compare
|
One thing I noticed: when archiving a team, you should remove the team access from other repos, like it was done in #2214 EDIT: actually you already have the logic to remove teams from a repo so maybe it's not that difficult! |
f595a4d to
dcb2e59
Compare
|
I added a |
| tempfile = "3.19.1" | ||
| thiserror = "2.0.18" | ||
| toml = "1.0" | ||
| toml_edit = "0.22" |
There was a problem hiding this comment.
Why not using the latest version of this package? I.e. what cargo add adds.
| remove_team_from_repos(data_dir, name)?; | ||
|
|
||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
this function is very long. I would extract it into smaller ones.
| std::fs::create_dir_all(&dest_dir) | ||
| .with_context(|| format!("failed to create directory {}", dest_dir.display()))?; | ||
| std::fs::write(&dest, doc.to_string()) | ||
| .with_context(|| format!("failed to write {}", dest.display()))?; | ||
| std::fs::remove_file(&src).with_context(|| format!("failed to remove {}", src.display()))?; |
There was a problem hiding this comment.
this code is duplicated among the two functions. So it would be nice to extract it into a function and reuse it.
In general, please inspect your code and find opportunities similar to this one to extract common code.
| if let Some(access) = doc.get_mut("access") | ||
| && let Some(teams) = access.get_mut("teams") | ||
| && let Some(table) = teams.as_table_mut() | ||
| { | ||
| table.clear(); | ||
| } |
There was a problem hiding this comment.
this code is also duplicated with the other function. It would be nice to extract it


This PR adds a new archive subcommand to the CLI that handles moving TOML files to the archive/ directory, clearing team access on repos, and moving team members to alumni .
Example usage:
cargo run -- archive repo rust-lang/homucargo run -- archive team project-generic-associated-typesFor repos, it moves the file to repos/archive/{org}/ and clears all entries under
[access.teams].For teams, it moves the file to teams/archive/, sets leads and members to empty, and moves everyone into alumni.
I used toml_edit to modify the TOML files so that only the parts that need to change are touched everything else (comments, formatting, ordering) stays the same.
Closes #1547