diff --git a/client/core/rs/src/entities/mod.rs b/client/core/rs/src/entities/mod.rs index 1f155a454..555fdc786 100644 --- a/client/core/rs/src/entities/mod.rs +++ b/client/core/rs/src/entities/mod.rs @@ -500,6 +500,7 @@ pub struct CloneArgs { pub repo: Option, pub branch: Option, pub commit: Option, + pub destination: Option, pub on_clone: Option, pub on_pull: Option, pub github_account: Option, @@ -512,6 +513,7 @@ impl From<&self::build::Build> for CloneArgs { repo: optional_string(&build.config.repo), branch: optional_string(&build.config.branch), commit: optional_string(&build.config.commit), + destination: None, on_clone: build.config.pre_build.clone().into_option(), on_pull: None, github_account: optional_string(&build.config.github_account), @@ -526,6 +528,7 @@ impl From<&self::repo::Repo> for CloneArgs { repo: optional_string(&repo.config.repo), branch: optional_string(&repo.config.branch), commit: optional_string(&repo.config.commit), + destination: optional_string(&repo.config.path), on_clone: repo.config.on_clone.clone().into_option(), on_pull: repo.config.on_pull.clone().into_option(), github_account: optional_string(&repo.config.github_account), @@ -541,6 +544,7 @@ impl From<&self::sync::ResourceSync> for CloneArgs { branch: optional_string(&sync.config.branch), commit: optional_string(&sync.config.commit), github_account: optional_string(&sync.config.github_account), + destination: None, on_clone: None, on_pull: None, } diff --git a/client/core/rs/src/entities/repo.rs b/client/core/rs/src/entities/repo.rs index 9c092ad05..ca03f8f13 100644 --- a/client/core/rs/src/entities/repo.rs +++ b/client/core/rs/src/entities/repo.rs @@ -99,6 +99,11 @@ pub struct RepoConfig { #[builder(default)] pub github_account: String, + /// Explicitly specificy the folder to clone the repo in. + #[serde(default)] + #[builder(default)] + pub path: String, + /// Command to be run after the repo is cloned. /// The path is relative to the root of the repo. #[serde(default)] @@ -140,6 +145,7 @@ impl Default for RepoConfig { branch: default_branch(), commit: Default::default(), github_account: Default::default(), + path: Default::default(), on_clone: Default::default(), on_pull: Default::default(), webhook_enabled: default_webhook_enabled(), diff --git a/client/core/ts/src/types.ts b/client/core/ts/src/types.ts index 94567c6fa..df6b88710 100644 --- a/client/core/ts/src/types.ts +++ b/client/core/ts/src/types.ts @@ -782,6 +782,8 @@ export interface RepoConfig { * It must be available in the server's periphery config. */ github_account?: string; + /** Explicitly specificy the folder to clone the repo in. */ + path?: string; /** * Command to be run after the repo is cloned. * The path is relative to the root of the repo. @@ -3658,6 +3660,7 @@ export interface CloneArgs { repo?: string; branch?: string; commit?: string; + destination?: string; on_clone?: SystemCommand; on_pull?: SystemCommand; github_account?: string; diff --git a/frontend/src/components/resources/repo/config.tsx b/frontend/src/components/resources/repo/config.tsx index 422f4758a..e0bf2177a 100644 --- a/frontend/src/components/resources/repo/config.tsx +++ b/frontend/src/components/resources/repo/config.tsx @@ -52,6 +52,9 @@ export const RepoConfig = ({ id }: { id: string }) => { repo: { placeholder: "Enter repo" }, branch: { placeholder: "Enter branch" }, commit: { placeholder: "Enter specific commit hash. Optional." }, + path: { + placeholder: "Enter a specific clone path. Optional.", + }, github_account: (value, set) => { const server_id = update.server_id || config.server_id; return ( diff --git a/lib/git/src/lib.rs b/lib/git/src/lib.rs index 2f4bdd19b..0f8338d15 100644 --- a/lib/git/src/lib.rs +++ b/lib/git/src/lib.rs @@ -1,4 +1,7 @@ -use std::path::Path; +use std::{ + path::{Path, PathBuf}, + str::FromStr, +}; use anyhow::Context; use command::run_monitor_command; @@ -77,6 +80,7 @@ where repo, branch, commit, + destination, on_clone, on_pull, .. @@ -85,7 +89,11 @@ where let repo = repo.as_ref().context("build has no repo attached")?; let name = to_monitor_name(&name); - let repo_dir = repo_dir.join(name); + let repo_dir = match destination { + Some(destination) => PathBuf::from_str(&destination) + .context("destination is not valid path")?, + None => repo_dir.join(name), + }; let mut logs = clone_inner(repo, &repo_dir, &branch, &commit, github_token)