pull repos
This commit is contained in:
@@ -11,5 +11,6 @@ octopush_core = { path = "../octopush_core" }
|
||||
|
||||
eyre = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
clap = { version = "4.0.18" }
|
||||
|
@@ -1,4 +1,7 @@
|
||||
use std::path::{self, PathBuf};
|
||||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use octopush_core::schema::{self, models::Action};
|
||||
use octopush_infra::service_register::ServiceRegister;
|
||||
|
||||
pub fn execute_cmd() -> Command {
|
||||
@@ -16,17 +19,39 @@ pub fn execute_cmd() -> Command {
|
||||
}
|
||||
|
||||
pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
let _action = args
|
||||
let action = args
|
||||
.get_one::<String>("action")
|
||||
.ok_or(eyre::anyhow!("--action is required"))?;
|
||||
|
||||
let service_register = ServiceRegister::new();
|
||||
|
||||
service_register
|
||||
.git_provider
|
||||
.clone_from_url("https://git.front.kjuulh.io/kjuulh/cuddle".to_string())
|
||||
let action_path: PathBuf = action.into();
|
||||
|
||||
let schema = service_register
|
||||
.schema_parser
|
||||
.parse_file(action_path.join("octopush.yml"))
|
||||
.await?;
|
||||
|
||||
match schema {
|
||||
schema::models::Schema::Action {
|
||||
name,
|
||||
select,
|
||||
actions,
|
||||
} => {
|
||||
tracing::debug!(name, "running action");
|
||||
|
||||
let mut repo_clones = Vec::with_capacity(select.repositories.len());
|
||||
for repo in select.repositories {
|
||||
let gp = service_register.git_provider.clone();
|
||||
repo_clones.push(tokio::spawn(async move { gp.clone_from_url(repo).await }));
|
||||
}
|
||||
|
||||
for repo_clone in repo_clones {
|
||||
let report = repo_clone.await??;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
service_register.cleanup().await?;
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user