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 comment has been minimized.
This comment has been minimized.
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
dcb2e59 to
ce7b140
Compare
|
Thanks for pointing that out. I have extracted the [access.teams] navigation into a shared get_access_teams helper and updated both archive_repo and remove_team_from_repos to use it. |
ubiratansoares
left a comment
There was a problem hiding this comment.
@Sandijigs Added some comments
| let mut all_alumni: Vec<String> = Vec::new(); | ||
| let mut seen = HashSet::new(); |
There was a problem hiding this comment.
Could we use only the hashset here?
There was a problem hiding this comment.
Thanks for pointing this out , Should I switch IndexSet from indexmap? since it handles both deduplication and preserves insertion order in a single data structure. which was what I was going for when i used hashset
| people_table.insert("leads", toml_edit::value(toml_edit::Array::new())); | ||
| people_table.insert("members", toml_edit::value(toml_edit::Array::new())); |
There was a problem hiding this comment.
It seems that
toml_edit::Array::new().into()works equality as
toml_edit::value(toml_edit::Array::new())but it reads a bit shorter (also better, imho)
This comment has been minimized.
This comment has been minimized.
ce7b140 to
323852a
Compare
323852a to
fb54a10
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. |
|
I've switched to IndexSet instead of the HashSet combo , It is definately more cleaner. Also swapped toml_edit::value() for .into() like @ubiratansoares suggested |


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