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