with dry-run mode (#42)
Co-authored-by: kjuulh <contact@kjuulh.io> Reviewed-on: #42
This commit is contained in:
parent
ef28a7a248
commit
e0d0077109
@ -58,6 +58,13 @@ pub fn execute_cmd() -> Command {
|
||||
.env("GITHUB_USERNAME")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("dry-run")
|
||||
.long("dry-run")
|
||||
.action(ArgAction::Set)
|
||||
.env("OCTOPUSH_DRY_RUN")
|
||||
.required(false),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
@ -71,6 +78,7 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
|
||||
let github_http_token = args.get_one::<String>("github-api-token");
|
||||
let github_username = args.get_one::<String>("github-username");
|
||||
let dryrun = args.get_one::<bool>("dry-run").unwrap_or(&false).clone();
|
||||
|
||||
let service_register = ServiceRegister::new(
|
||||
LocalGitProviderOptions { http_auth: None },
|
||||
@ -107,21 +115,21 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
|
||||
if let Some(git) = &select.git {
|
||||
service_register
|
||||
.git_selector
|
||||
.run(git, &action_path, &action)
|
||||
.run(git, &action_path, &action, dryrun)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(gitea) = &select.gitea {
|
||||
service_register
|
||||
.gitea_selector
|
||||
.run(gitea, &action_path, &action)
|
||||
.run(gitea, &action_path, &action, dryrun)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(github) = &select.github {
|
||||
service_register
|
||||
.github_selector
|
||||
.run(github, &action_path, &action)
|
||||
.run(github, &action_path, &action, dryrun)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,13 @@ impl GitSelector {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run(&self, git: &Git, action_path: &PathBuf, action: &Action) -> eyre::Result<()> {
|
||||
pub async fn run(
|
||||
&self,
|
||||
git: &Git,
|
||||
action_path: &PathBuf,
|
||||
action: &Action,
|
||||
dryrun: bool,
|
||||
) -> eyre::Result<()> {
|
||||
tracing::info!("fetching repos");
|
||||
for repo in &git.repositories {
|
||||
let gp = self.git_provider.clone();
|
||||
@ -36,6 +42,10 @@ impl GitSelector {
|
||||
|
||||
self.executor.execute(&path, action_path, action).await?;
|
||||
|
||||
if dryrun {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(push) = &git.push {
|
||||
self.git_provider
|
||||
.push_branch(repo, &push.branch.name)
|
||||
|
@ -32,6 +32,7 @@ impl GiteaSelector {
|
||||
git: &Gitea,
|
||||
action_path: &PathBuf,
|
||||
action: &Action,
|
||||
dryrun: bool,
|
||||
) -> eyre::Result<()> {
|
||||
tracing::info!("fetching repos");
|
||||
for repo in &git.repositories {
|
||||
@ -47,6 +48,10 @@ impl GiteaSelector {
|
||||
|
||||
self.executor.execute(&path, action_path, action).await?;
|
||||
|
||||
if dryrun {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(push) = &git.push {
|
||||
self.git_provider
|
||||
.push_branch(repo, &push.pull_request.name)
|
||||
|
@ -32,6 +32,7 @@ impl GitHubSelector {
|
||||
git: &GitHub,
|
||||
action_path: &PathBuf,
|
||||
action: &Action,
|
||||
dryrun: bool,
|
||||
) -> eyre::Result<()> {
|
||||
tracing::info!("fetching repos");
|
||||
for repo in &git.repositories {
|
||||
@ -47,6 +48,10 @@ impl GitHubSelector {
|
||||
|
||||
self.executor.execute(&path, action_path, action).await?;
|
||||
|
||||
if dryrun {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(push) = &git.push {
|
||||
self.git_provider
|
||||
.push_branch(repo, &push.pull_request.name)
|
||||
|
Loading…
Reference in New Issue
Block a user