Skip to content

Added CLI command to automate team and repo archival#2420

Open
Sandijigs wants to merge 1 commit intorust-lang:mainfrom
Sandijigs:add/archive-command
Open

Added CLI command to automate team and repo archival#2420
Sandijigs wants to merge 1 commit intorust-lang:mainfrom
Sandijigs:add/archive-command

Conversation

@Sandijigs
Copy link
Copy Markdown
Contributor

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/homu

  • cargo run -- archive team project-generic-associated-types

For 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

@rustbot

This comment has been minimized.

@Sandijigs Sandijigs force-pushed the add/archive-command branch from f71bf56 to 9335836 Compare April 15, 2026 20:49
@rustbot
Copy link
Copy Markdown

rustbot commented Apr 15, 2026

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.

@Sandijigs Sandijigs force-pushed the add/archive-command branch from 9335836 to dfedaf1 Compare April 15, 2026 21:11
@github-actions
Copy link
Copy Markdown

Dry-run check results

[WARN  rust_team::sync] sync-team is running in dry mode, no changes will be applied.
[INFO  rust_team::sync] synchronizing crates-io
[INFO  rust_team::sync] synchronizing github

@marcoieni
Copy link
Copy Markdown
Member

I tested archiving a team, but alumni are in one line. Can we put one member per line?
image

@Sandijigs Sandijigs force-pushed the add/archive-command branch from dfedaf1 to f595a4d Compare April 15, 2026 21:40
@Sandijigs
Copy link
Copy Markdown
Contributor Author

The alumni are now listed one per line.

Screenshot 2026-04-15 at 10 37 38 pm

@marcoieni
Copy link
Copy Markdown
Member

marcoieni commented Apr 15, 2026

One thing I noticed: when archiving a team, you should remove the team access from other repos, like it was done in #2214
Probably this is more complicated, so no need to do this if you don't have time.

EDIT: actually you already have the logic to remove teams from a repo so maybe it's not that difficult!

@Sandijigs Sandijigs force-pushed the add/archive-command branch from f595a4d to dcb2e59 Compare April 16, 2026 20:47
@Sandijigs
Copy link
Copy Markdown
Contributor Author

I added a remove_team_from_repos function that runs after the team file is archived. It scans all repo TOML files and removes the archived team's entry from any [access.teams] block where it appears.

Comment thread Cargo.toml
tempfile = "3.19.1"
thiserror = "2.0.18"
toml = "1.0"
toml_edit = "0.22"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the latest version of this package? I.e. what cargo add adds.

Comment thread src/main.rs
remove_team_from_repos(data_dir, name)?;

Ok(())
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is very long. I would extract it into smaller ones.

Comment thread src/main.rs
Comment on lines +708 to +712
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()))?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main.rs
Comment on lines +701 to +706
if let Some(access) = doc.get_mut("access")
&& let Some(teams) = access.get_mut("teams")
&& let Some(table) = teams.as_table_mut()
{
table.clear();
}
Copy link
Copy Markdown
Member

@marcoieni marcoieni Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is also duplicated with the other function. It would be nice to extract it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a command for archiving teams and repos

3 participants