Skip to content

Commit 1e6d0f3

Browse files
committed
Allow overriding upstream commit to pull from
1 parent c995bc9 commit 1e6d0f3

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/bin/rustc_josh_sync.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,36 @@ enum Command {
2727
/// Can be used to perform experimental pulls e.g. to test changes in the subtree repository
2828
/// that have not yet been merged in `rust-lang/rust`.
2929
#[clap(long, default_value(DEFAULT_UPSTREAM_REPO))]
30-
upstream: String,
30+
upstream_repo: String,
31+
32+
/// Path to the josh-sync TOML config file.
3133
#[clap(long, default_value(DEFAULT_CONFIG_PATH))]
3234
config_path: PathBuf,
35+
36+
/// Path to a file storing the last synchronized rustc commit.
3337
#[clap(long, default_value(DEFAULT_RUST_VERSION_PATH))]
3438
rust_version_path: PathBuf,
39+
40+
/// Override the rustc commit that we should pull from.
41+
/// By default, josh-sync will pull from rustc's HEAD (latest commit).
42+
#[clap(long)]
43+
upstream_commit: Option<String>,
3544
},
3645
/// Push changes into the main `rust-lang/rust` repository `branch` of a `rustc` fork under
3746
/// the given GitHub `username`.
3847
/// The pushed branch should then be merged into the `rustc` repository.
3948
Push {
49+
/// Path to the josh-sync TOML config file.
4050
#[clap(long, default_value(DEFAULT_CONFIG_PATH))]
4151
config_path: PathBuf,
52+
53+
/// Path to a file storing the last synchronized rustc commit.
4254
#[clap(long, default_value(DEFAULT_RUST_VERSION_PATH))]
4355
rust_version_path: PathBuf,
56+
4457
/// Branch that should be pushed to your remote
4558
branch: String,
59+
4660
/// Your GitHub usename where the fork is located
4761
username: String,
4862
},
@@ -74,12 +88,13 @@ fn main() -> anyhow::Result<()> {
7488
Command::Pull {
7589
config_path,
7690
rust_version_path,
77-
upstream,
91+
upstream_repo,
92+
upstream_commit,
7893
} => {
7994
let ctx = load_context(&config_path, &rust_version_path)?;
8095
let josh = get_josh_proxy()?;
8196
let sync = GitSync::new(ctx.clone(), josh);
82-
match sync.rustc_pull(upstream) {
97+
match sync.rustc_pull(upstream_repo, upstream_commit) {
8398
Ok(result) => {
8499
if !maybe_create_gh_pr(
85100
&ctx.config.full_repo_name(),

src/sync.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ impl GitSync {
3535
Self { context, proxy }
3636
}
3737

38-
pub fn rustc_pull(&self, upstream_repo: String) -> Result<PullResult, RustcPullError> {
38+
pub fn rustc_pull(
39+
&self,
40+
upstream_repo: String,
41+
upstream_commit: Option<String>,
42+
) -> Result<PullResult, RustcPullError> {
3943
// The upstream commit that we want to pull
40-
let upstream_sha = {
44+
let upstream_sha = if let Some(sha) = upstream_commit {
45+
sha
46+
} else {
4147
let out = run_command([
4248
"git",
4349
"ls-remote",

0 commit comments

Comments
 (0)