feature/dry-run #43

Merged
kjuulh merged 1 commits from feature/dry-run into main 2022-12-01 09:14:02 +01:00
5 changed files with 24 additions and 16 deletions

View File

@ -1,12 +1,12 @@
apiVersion: action apiVersion: action
name: write-a-readme name: write-a-readme
select: select:
github: # github:
repositories: # repositories:
- kjuulh/octopush-test # - kjuulh/octopush-test
push: # push:
pull-request: # pull-request:
name: "write a readme" # name: "write a readme"
gitea: gitea:
repositories: repositories:
@ -15,12 +15,12 @@ select:
pull-request: pull-request:
name: "write a readme" name: "write a readme"
git: # git:
repositories: # repositories:
- git@git.front.kjuulh.io:kjuulh/octopush-test.git # - git@git.front.kjuulh.io:kjuulh/octopush-test.git
push: # push:
branch: # branch:
name: "write a readme" # name: "write a readme"
action: action:
type: go type: go
entry: "main.go" entry: "main.go"

View File

@ -63,6 +63,7 @@ pub fn execute_cmd() -> Command {
.long("dry-run") .long("dry-run")
.action(ArgAction::Set) .action(ArgAction::Set)
.env("OCTOPUSH_DRY_RUN") .env("OCTOPUSH_DRY_RUN")
.default_value("true")
.required(false), .required(false),
) )
} }
@ -78,7 +79,14 @@ 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 dryrun: bool = args
.get_one::<String>("dry-run")
.ok_or(eyre::anyhow!("--dry-run is required"))?
.parse()?;
if dryrun {
tracing::info!("running in dry-run mode");
}
let service_register = ServiceRegister::new( let service_register = ServiceRegister::new(
LocalGitProviderOptions { http_auth: None }, LocalGitProviderOptions { http_auth: None },

View File

@ -43,7 +43,7 @@ impl GitSelector {
self.executor.execute(&path, action_path, action).await?; self.executor.execute(&path, action_path, action).await?;
if dryrun { if dryrun {
return Ok(()); continue;
} }
if let Some(push) = &git.push { if let Some(push) = &git.push {

View File

@ -49,7 +49,7 @@ impl GiteaSelector {
self.executor.execute(&path, action_path, action).await?; self.executor.execute(&path, action_path, action).await?;
if dryrun { if dryrun {
return Ok(()); continue;
} }
if let Some(push) = &git.push { if let Some(push) = &git.push {

View File

@ -49,7 +49,7 @@ impl GitHubSelector {
self.executor.execute(&path, action_path, action).await?; self.executor.execute(&path, action_path, action).await?;
if dryrun { if dryrun {
return Ok(()); continue;
} }
if let Some(push) = &git.push { if let Some(push) = &git.push {