fix commit
This commit is contained in:
@@ -13,4 +13,4 @@ eyre = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
clap = { version = "4.0.18" }
|
||||
clap = { version = "4.0.18", features = ["env"] }
|
||||
|
@@ -1,7 +1,10 @@
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use octopush_core::schema;
|
||||
use octopush_core::{
|
||||
git::{git::LocalGitProviderOptions, gitea::client::DefaultGiteaClientOptions},
|
||||
schema,
|
||||
};
|
||||
use octopush_infra::service_register::ServiceRegister;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
@@ -17,6 +20,12 @@ pub fn execute_cmd() -> Command {
|
||||
.long_help("action path to your local octopush.yaml file")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("gitea-http-token")
|
||||
.long("gitea-http-token")
|
||||
.action(ArgAction::Set)
|
||||
.required(false),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
@@ -24,7 +33,17 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
.get_one::<String>("action")
|
||||
.ok_or(eyre::anyhow!("--action is required"))?;
|
||||
|
||||
let service_register = ServiceRegister::new();
|
||||
let gitea_http_token = args.get_one::<String>("gitea-http-token");
|
||||
|
||||
let service_register = ServiceRegister::new(
|
||||
LocalGitProviderOptions {
|
||||
http_auth: gitea_http_token.map(|t| t.clone()),
|
||||
},
|
||||
DefaultGiteaClientOptions {
|
||||
url: "https://git.front.kjuulh.io/api/v1".into(),
|
||||
basicauth: Some("kjuulh:379341972ba6d23ff85367ca1c10c82efea76f0c".into()),
|
||||
},
|
||||
);
|
||||
|
||||
let action_path: PathBuf = action.into();
|
||||
|
||||
@@ -57,13 +76,15 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
}
|
||||
|
||||
let mut gitea_paths = Vec::new();
|
||||
if let Some(gitea) = &select.gitea {
|
||||
if let Some(gitea) = select.gitea.clone() {
|
||||
let mut repo_clones = Vec::with_capacity(gitea.repositories.len());
|
||||
for repo in gitea.repositories {
|
||||
let gp = service_register.gitea_provider.clone();
|
||||
repo_clones.push(tokio::spawn(
|
||||
async move { gp.clone_from_qualified(repo).await },
|
||||
))
|
||||
repo_clones.push(tokio::spawn(async move {
|
||||
gp.clone_from_qualified(repo.clone())
|
||||
.await
|
||||
.map(|(p, r)| (p, r, repo))
|
||||
}))
|
||||
}
|
||||
|
||||
for repo_clone in repo_clones {
|
||||
@@ -78,7 +99,7 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
if let Some(push) = git.push {
|
||||
service_register
|
||||
.git_provider
|
||||
.create_branch(repo.clone(), &push.branch)
|
||||
.create_branch(repo.clone(), &push.branch.name)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +113,33 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
if let Some(push) = git.push {
|
||||
service_register
|
||||
.git_provider
|
||||
.push_branch(repo, &push.branch)
|
||||
.push_branch(repo, &push.branch.name)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (path, repo, repo_name) in gitea_paths {
|
||||
let repo = Arc::new(Mutex::new(repo));
|
||||
if let Some(gitea) = select.gitea.clone() {
|
||||
if let Some(push) = gitea.push {
|
||||
service_register
|
||||
.gitea_provider
|
||||
.create_branch(repo.clone(), &push.pull_request)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
service_register
|
||||
.executor
|
||||
.execute(path.clone(), action_path.clone(), action.clone())
|
||||
.await?;
|
||||
|
||||
if let Some(gitea) = select.gitea.clone() {
|
||||
if let Some(push) = gitea.push {
|
||||
service_register
|
||||
.gitea_provider
|
||||
.create_pull_request(repo, &repo_name, &push.pull_request)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user