Skip to content

Add custom properties#2512

Open
Sandijigs wants to merge 4 commits into
rust-lang:mainfrom
Sandijigs:add-custom-properties
Open

Add custom properties#2512
Sandijigs wants to merge 4 commits into
rust-lang:mainfrom
Sandijigs:add-custom-properties

Conversation

@Sandijigs

Copy link
Copy Markdown
Contributor

Adds support for [custom-properties] in the team repo's TOML, and sets crabwatch = true on rust-lang/crabwatch.
Booleans only for now. Properties on a repo but not declared in TOML are left alone.
Closes #2504.

@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown

rust_team_data/src/v1.rs has been modified, it is used (as a git dependency) by multiple sub-projects like triagebot, the www.rust-lang.org website and others.

If you are changing the data structures, please make sure that the changes are not going to break serde deserialization (adding a field is fine; removing or renaming a field isn't).

If you must do a breaking change to the format, make sure to coordinate it with all the users of the rust_team_data crate.

@github-actions

github-actions Bot commented Jun 9, 2026

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

@jieyouxu jieyouxu added needs-infra-admin-review This change requires one of the `infra-admins` to review. S-waiting-on-review Status: waiting on review from a team/WG/PG lead, an infra-admin, and/or a team-repo-admin. labels Jun 10, 2026

@ubiratansoares ubiratansoares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Sandijigs thanks for this PR, looks we are in the right direction here. Added a few comments :)

Comment thread src/sync/github/mod.rs
Comment on lines +902 to +909
let operation = match actual_by_name.get(name) {
// Missing on the repo, or value is null.
None | Some(None) => CustomPropertyDiffOperation::Create(expected),
Some(Some(actual)) if actual != &expected => {
CustomPropertyDiffOperation::Update(actual.clone(), expected)
}
Some(Some(_)) => continue,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps is room to make this code more concise with some pattern matching tricks. I'd recommend having a look on how to change

let operation = match actual_by_name.get(name)

in order to get rid of the nested Option value :)

"auto_merge_enabled": true
"auto_merge_enabled": true,
"custom_properties": {}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probaly a good idea adding an empty line in these files, so we keep the standard

Comment thread src/sync/github/mod.rs
Ok(ruleset_diffs)
}

async fn diff_custom_properties(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I missed some tests that actually prove this function works as intended in sync/github/tests/mod.rs.

I propose adding at least two cases :

  • adding a propery to a repo
  • removing a property from a repo

Comment thread rust_team_data/src/v1.rs
// https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request
pub auto_merge_enabled: bool,
#[serde(default)]
pub custom_properties: BTreeMap<String, bool>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general we've been using IndexMap to represent key-value pairs in this file. Do you have any particular reason to go with BTreeMap instead?

@Kobzol Kobzol left a comment

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.

Left a few comments :)

Comment thread rust_team_data/src/v1.rs
// Is the GitHub "Auto-merge" option enabled?
// https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request
pub auto_merge_enabled: bool,
#[serde(default)]

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.

The #[serde(default)] annotation is not necessary, because the generator (the team API CI) will be updated sooner than the consumers (the crates that depend on the team crate).

Comment thread src/sync/github/mod.rs
#[derive(Debug)]
enum CustomPropertyDiffOperation {
Create(String),
Update(String, String), // old, new

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 should perhaps also contain Delete, in case the custom property is removed from the team config.

It would mean that team is the ground truth for all our custom properties, although it would also delete all custom properties that are not set in team.

@ubiratansoares Do you want team to be the ground truth for all custom properties? If it is not, then once a property is created through team, it won't ever be deleted again.

Comment thread docs/toml-schema.md
# Repository custom properties (optional)
[custom-properties]
# Set a property name to a boolean value
crabwatch = true

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.

The property values on GitHub are strings, and the code currently converts bools to a string via its Display impl, which is a bit opaque and potentially fragile. Maybe we could just expose the value as a string?

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

Labels

needs-infra-admin-review This change requires one of the `infra-admins` to review. S-waiting-on-review Status: waiting on review from a team/WG/PG lead, an infra-admin, and/or a team-repo-admin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting repository custom properties

5 participants