Skip to content

Add symmetry filter support and improve round-trip check#38

Open
makai410 wants to merge 1 commit intorust-lang:mainfrom
makai410:feat/scope
Open

Add symmetry filter support and improve round-trip check#38
makai410 wants to merge 1 commit intorust-lang:mainfrom
makai410:feat/scope

Conversation

@makai410
Copy link
Member

@makai410 makai410 commented Mar 20, 2026

Fixes: #37

To explain what the symmetry filter is, here's an example with rustc_public:

org = "rust-lang"
repo = "project-stable-mir"
filter = ":/compiler/rustc_public:exclude[:[::build.rs,::tests/,::Cargo.toml]]:prefix=rustc_public"
sym-filter = ":/rustc_public:exclude[:[::build.rs,::tests/,::Cargo.toml]]:prefix=rustc_public"

The filter is applied to the rust-lang/rust side, while sym-filter is applied to the rust-lang/project-stable-mir side. Ideally, both should produce the same SHA, confirming a successful round-trip.

For repos doing a 1:1 mirror, sym-filter should be empty, in that case this PR will not download the josh-filter tool.

And basically, the round-trip check in this PR looks like:

$ git fetch <josh_url with the `filter`> <branch>
# if the `sym-filter` is set
  # install the josh-filter tool
  $ cargo install josh-cli --git https://github.com/josh-project/josh.git
  $ josh-filter "<sym-filter>" HEAD
  $ git rev-parse FILTERED_HEAD
  $ git rev-parse FETCH_HEAD
  # then compare FILTERED_HEAD and FETCH_HEAD
# else
  $ git rev-parse HEAD
  $ git rev-parse FETCH_HEAD
  # then compare HEAD and FETCH_HEAD

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

We should probably start using the new Josh CLI in josh-sync, I feel like we are reimplementing a lot of stuff in josh-sync that is already there as a single command :) In any case, if this helps your use-case, it seems fine.

I would maybe rename sym-filter to subtree-filter or something, to make it more explicit about what it does, but it doesn't matter much, sym-filter is fine too.

}

pub fn try_install_josh_filter(verbose: bool) -> Option<JoshFilter> {
run_command(
Copy link
Member

Choose a reason for hiding this comment

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

Can you please pin the version/tag/commit SHA? I don't want josh-sync to install unpinned versions of Josh, we had enough trouble with that in the past.

}
}

pub fn run_command_by_path<'a, Args: AsRef<[&'a str]>>(
Copy link
Member

Choose a reason for hiding this comment

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

Why was a new function needed here?

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub post_pull: Vec<PostPullOperation>,
/// Optional symmetry filter applied to the local `HEAD` during round-trip check.
pub sym_filter: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub sym_filter: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sym_filter: Option<String>,

Otherwise the config would fail to be parsed if the field is missing, I think.

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.

More robust round-trip check

2 participants