@smbcloud / cli / commits / d753fcc

Use runner-specific git host in remote setup

Seto Elkahfi committed Jun 28, 2025 at 16:44 UTC d753fcc11baa11529db9bcaab700d3acf226c894
3 files changed +15 -4
crates/cli/src/deploy/git.rs
+4 -2
@@ -1,3 +1,4 @@
1 +use crate::project::runner::Runner;
2 use crate::ui::{fail_message, fail_symbol, succeed_message, succeed_symbol};
3 use anyhow::{anyhow, Result};
4 use console::style;
@@ -5,6 +6,7 @@ use git2::{Remote, Repository};
6 use spinners::Spinner;
7
8 pub async fn remote_deployment_setup<'a>(
9 + runner: &Runner,
10 repo: &'a Repository,
11 repo_name: &'a str,
12 ) -> Result<Remote<'a>> {
@@ -36,11 +38,11 @@ pub async fn remote_deployment_setup<'a>(
38 .bold()
39 .to_string(),
40 );
39 - let remote_format = format!("{}.git", repo_name);
41 + let repo_name_format = format!("{}.git", repo_name);
42 let remote = repo
43 .remote(
44 "smbcloud",
43 - &format!("git@api.smbcloud.xyz:{}", remote_format),
45 + &format!("{}:{}", runner.git_host(), repo_name_format),
46 )
47 .map_err(|e: git2::Error| {
48 spinner.stop_and_persist(&fail_symbol(), e.to_string());
crates/cli/src/deploy/mod.rs
+2 -2
@@ -38,7 +38,7 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
38 let config = check_config(env).await?;
39
40 // Check runner.
41 - detect_runner().await?;
41 + let runner = detect_runner().await?;
42
43 // Validate config with project.
44 check_project(env, &access_token, config.project.id).await?;
@@ -62,7 +62,7 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
62 }
63 };
64
65 - let mut origin = remote_deployment_setup(&repo, &config.project.repository).await?;
65 + let mut origin = remote_deployment_setup(&runner, &repo, &config.project.repository).await?;
66
67 let commit_hash = match main_branch.resolve() {
68 Ok(result) => match result.target() {
crates/cli/src/project/runner.rs
+9
@@ -9,6 +9,15 @@ pub(crate) enum Runner {
9 Swift,
10 }
11
12 +impl Runner {
13 + pub fn git_host(&self) -> &str {
14 + match self {
15 + Runner::Swift => "git@api.musik88.com",
16 + _ => "git@api.smbcloud.xyz",
17 + }
18 + }
19 +}
20 +
21 pub(crate) async fn detect_runner() -> Result<Runner> {
22 let mut spinner: Spinner = Spinner::new(
23 spinners::Spinners::SimpleDotsScrolling,