@smbcloud / cli / commits / 0667dac

handle git branch errors

Seto Elkahfi committed May 31, 2025 at 18:53 UTC 0667dac97344f9a77e1d1d9cc0ee1254b1b25b52
1 file changed +9 -2
crates/cli/src/deploy/mod.rs
+9 -2
@@ -59,9 +59,9 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
59 let commit_hash = match main_branch.resolve() {
60 Ok(result) => match result.target() {
61 Some(hash_id) => hash_id,
62 - None => todo!(),
62 + None => return Err(anyhow!("Should have at least one commit.")),
63 },
64 - Err(_) => todo!(),
64 + Err(_) => return Err(anyhow!("Cannot resolve main branch.")),
65 };
66 let payload = DeploymentPayload {
67 commit_hash: commit_hash.to_string(),
@@ -73,6 +73,13 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
73
74 let mut push_opts = PushOptions::new();
75 let mut callbacks = RemoteCallbacks::new();
76 +
77 + // For updating status to failed
78 + let deployment_failed_flag = Arc::new(AtomicBool::new(false));
79 + let update_access_token = access_token.clone();
80 + let update_project_id = config.project.id.clone();
81 + let update_deployment_id = created_deployment.id.clone();
82 +
83 // Set the credentials
84 callbacks.credentials(config.credentials(user));
85 callbacks.sideband_progress(|data| {