Unverified Commit 4fdb6bbe authored by Zelda Hessler's avatar Zelda Hessler Committed by GitHub
Browse files

fix: exit with error code on failure (#1014)

add: print directories at start
parent b828dc80
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -59,20 +59,28 @@ pub(crate) use here;
/// --smithy-rs /Users/zhessler/Documents/smithy-rs-test/ \
/// --aws-sdk /Users/zhessler/Documents/aws-sdk-rust-test/
/// ```
fn main() {
fn main() -> Result<()> {
    let Opt {
        smithy_rs,
        aws_sdk,
        branch,
    } = Opt::from_args();

    if let Err(e) = sync_aws_sdk_with_smithy_rs(&smithy_rs, &aws_sdk, &branch) {
        eprintln!("Sync failed with error: {:?}", e);
    };
    sync_aws_sdk_with_smithy_rs(&smithy_rs, &aws_sdk, &branch)
        .map_err(|e| e.context("The sync failed"))
}

/// Run through all commits made to `smithy-rs` since last sync and "replay" them onto `aws-sdk-rust`.
fn sync_aws_sdk_with_smithy_rs(smithy_rs: &Path, aws_sdk: &Path, branch: &str) -> Result<()> {
    eprintln!(
        "aws-sdk-rust path:\t{}",
        aws_sdk.canonicalize().context(here!())?.display()
    );
    eprintln!(
        "smithy-rs path:\t{}",
        smithy_rs.canonicalize().context(here!())?.display()
    );

    // Open the repositories we'll be working with
    let smithy_rs_repo = Repository::open(smithy_rs).context("couldn't open smithy-rs repo")?;
    let aws_sdk_repo = Repository::open(aws_sdk).context("couldn't open aws-sdk-rust repo")?;