-
Notifications
You must be signed in to change notification settings - Fork 5
Add --yolo flag to auto-approve fix prompts #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,6 +180,7 @@ where | |
| { | ||
| pub(crate) group_actions: BTreeMap<String, GroupActionContainer<T>>, | ||
| pub(crate) all_paths: Vec<String>, | ||
| pub(crate) yolo: bool, | ||
| } | ||
|
|
||
| impl<T> RunGroups<T> | ||
|
|
@@ -293,8 +294,9 @@ where | |
| )); | ||
| action_span.pb_set_style(&progress_bar_without_pos()); | ||
|
|
||
| let prompt_fn = if self.yolo { auto_approve } else { prompt_user }; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ Easy peezy. Like it. |
||
| let action_result = action | ||
| .run_action(prompt_user) | ||
| .run_action(prompt_fn) | ||
| .instrument(action_span.clone()) | ||
| .await?; | ||
|
|
||
|
|
@@ -362,6 +364,14 @@ fn prompt_user(prompt_text: &str, maybe_help_text: &Option<String>) -> bool { | |
| }) | ||
| } | ||
|
|
||
| fn auto_approve(prompt_text: &str, maybe_help_text: &Option<String>) -> bool { | ||
| println!("{} Yes (auto-approved)", prompt_text); | ||
| if let Some(help_text) = maybe_help_text { | ||
| println!("[{}]", help_text); | ||
| } | ||
| true | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if it is worth while to write the context of the prompt and help text with an additional log that it's being automatically applied. I can't quite picture in my head what the user experience or backend traces look like.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense - will do that |
||
| } | ||
|
|
||
| async fn report_action_output<T>( | ||
| group_name: &str, | ||
| action: &T, | ||
|
|
@@ -753,6 +763,7 @@ mod tests { | |
| "group_2".to_string(), | ||
| "group_3".to_string(), | ||
| ], | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let exit_code = run_groups.execute().await?; | ||
|
|
@@ -784,6 +795,7 @@ mod tests { | |
| "skipped_1".to_string(), | ||
| "skipped_2".to_string(), | ||
| ], | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let exit_code = run_groups.execute().await?; | ||
|
|
@@ -821,6 +833,7 @@ mod tests { | |
| "user_denies".to_string(), | ||
| "skipped".to_string(), | ||
| ], | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let exit_code = run_groups.execute().await?; | ||
|
|
@@ -868,6 +881,7 @@ mod tests { | |
| "user_denies".to_string(), | ||
| "succeeds_2".to_string(), | ||
| ], | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let exit_code = run_groups.execute().await?; | ||
|
|
@@ -911,6 +925,7 @@ mod tests { | |
| "fails".to_string(), | ||
| "succeeds_2".to_string(), | ||
| ], | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let exit_code = run_groups.execute().await?; | ||
|
|
@@ -1019,6 +1034,7 @@ mod tests { | |
| let run_groups = RunGroups { | ||
| group_actions: BTreeMap::new(), | ||
| all_paths: Vec::new(), | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let group_span = info_span!("test_group", "indicatif.pb_show" = true); | ||
|
|
@@ -1072,6 +1088,7 @@ mod tests { | |
| let run_groups = RunGroups { | ||
| group_actions: BTreeMap::new(), | ||
| all_paths: Vec::new(), | ||
| yolo: false, | ||
| }; | ||
|
|
||
| let group_span = info_span!("test_group", "indicatif.pb_show" = true); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: scope.github.com/v1alpha | ||
| kind: ScopeDoctorGroup | ||
| metadata: | ||
| name: prompt-test | ||
| description: Test fix that requires user confirmation | ||
| spec: | ||
| actions: | ||
| - name: needs-approval | ||
| description: A fix that needs user approval before running | ||
| check: | ||
| commands: | ||
| - test -f {{ working_dir }}/approved-file.txt | ||
| fix: | ||
| prompt: | ||
| text: "Do you want to create the file?" | ||
| extraContext: "This will create approved-file.txt" | ||
| commands: | ||
| - touch {{ working_dir }}/approved-file.txt |
Uh oh!
There was an error while loading. Please reload this page.