Skip to content

Commit

Permalink
Create repo before signaling bundle upload intent (#175)
Browse files Browse the repository at this point in the history
* Create repo before signaling bundle upload intent

* fix

* wip

* wip

* test
  • Loading branch information
pat-trunk-io authored Nov 23, 2024
1 parent a5fda4d commit 25ce229
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions cli-tests/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ async fn upload_bundle() {
})
);

assert_eq!(
requests_iter.next().unwrap(),
RequestPayload::CreateRepo(CreateRepoRequest {
repo: Repo {
host: String::from("github.com"),
owner: String::from("trunk-io"),
name: String::from("analytics-cli"),
},
org_url_slug: String::from("test-org"),
remote_urls: Vec::from(&[String::from(
"https://github.com/trunk-io/analytics-cli.git"
)]),
})
);

let upload_request = assert_matches!(requests_iter.next().unwrap(), RequestPayload::CreateBundleUpload(ur) => ur);
assert_eq!(
upload_request.repo,
Expand Down Expand Up @@ -161,21 +176,6 @@ async fn upload_bundle() {
}),
);

assert_eq!(
requests_iter.next().unwrap(),
RequestPayload::CreateRepo(CreateRepoRequest {
repo: Repo {
host: String::from("github.com"),
owner: String::from("trunk-io"),
name: String::from("analytics-cli"),
},
org_url_slug: String::from("test-org"),
remote_urls: Vec::from(&[String::from(
"https://github.com/trunk-io/analytics-cli.git"
)]),
})
);

// HINT: View CLI output with `cargo test -- --nocapture`
println!("{assert}");
}
Expand Down
20 changes: 10 additions & 10 deletions cli/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ pub async fn run_upload(
let envs = EnvScanner::scan_env();
let os_info: String = env::consts::OS.to_string();

api_client
.create_trunk_repo(&api::CreateRepoRequest {
repo: repo.repo.clone(),
org_url_slug: org_url_slug.clone(),
remote_urls: vec![repo.repo_url.clone()],
})
.await?;

let cli_version = format!(
"cargo={} git={} rustc={}",
env!("CARGO_PKG_VERSION"),
Expand All @@ -224,8 +232,8 @@ pub async fn run_upload(
let meta = BundleMeta {
base_props: BundleMetaBaseProps {
version: META_VERSION.to_string(),
org: org_url_slug.clone(),
repo: repo.clone(),
org: org_url_slug,
repo,
cli_version,
bundle_upload_id: upload.id.clone(),
tags,
Expand Down Expand Up @@ -305,14 +313,6 @@ pub async fn run_upload(
)
}

api_client
.create_trunk_repo(&api::CreateRepoRequest {
repo: repo.repo,
org_url_slug,
remote_urls: vec![repo.repo_url.clone()],
})
.await?;

if exit_code == EXIT_SUCCESS {
log::info!("Done");
} else {
Expand Down

0 comments on commit 25ce229

Please sign in to comment.