Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/bin/rustc_josh_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,36 @@ enum Command {
/// Can be used to perform experimental pulls e.g. to test changes in the subtree repository
/// that have not yet been merged in `rust-lang/rust`.
#[clap(long, default_value(DEFAULT_UPSTREAM_REPO))]
upstream: String,
upstream_repo: String,

/// Path to the josh-sync TOML config file.
#[clap(long, default_value(DEFAULT_CONFIG_PATH))]
config_path: PathBuf,

/// Path to a file storing the last synchronized rustc commit.
#[clap(long, default_value(DEFAULT_RUST_VERSION_PATH))]
rust_version_path: PathBuf,

/// Override the rustc commit that we should pull from.
/// By default, josh-sync will pull from rustc's HEAD (latest commit).
#[clap(long)]
upstream_commit: Option<String>,
},
/// Push changes into the main `rust-lang/rust` repository `branch` of a `rustc` fork under
/// the given GitHub `username`.
/// The pushed branch should then be merged into the `rustc` repository.
Push {
/// Path to the josh-sync TOML config file.
#[clap(long, default_value(DEFAULT_CONFIG_PATH))]
config_path: PathBuf,

/// Path to a file storing the last synchronized rustc commit.
#[clap(long, default_value(DEFAULT_RUST_VERSION_PATH))]
rust_version_path: PathBuf,

/// Branch that should be pushed to your remote
branch: String,

/// Your GitHub usename where the fork is located
username: String,
},
Expand Down Expand Up @@ -74,12 +88,13 @@ fn main() -> anyhow::Result<()> {
Command::Pull {
config_path,
rust_version_path,
upstream,
upstream_repo,
upstream_commit,
} => {
let ctx = load_context(&config_path, &rust_version_path)?;
let josh = get_josh_proxy()?;
let sync = GitSync::new(ctx.clone(), josh);
match sync.rustc_pull(upstream) {
match sync.rustc_pull(upstream_repo, upstream_commit) {
Ok(result) => {
if !maybe_create_gh_pr(
&ctx.config.full_repo_name(),
Expand Down
10 changes: 8 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ impl GitSync {
Self { context, proxy }
}

pub fn rustc_pull(&self, upstream_repo: String) -> Result<PullResult, RustcPullError> {
pub fn rustc_pull(
&self,
upstream_repo: String,
upstream_commit: Option<String>,
) -> Result<PullResult, RustcPullError> {
// The upstream commit that we want to pull
let upstream_sha = {
let upstream_sha = if let Some(sha) = upstream_commit {
sha
} else {
let out = run_command([
"git",
"ls-remote",
Expand Down
Loading