@@ -117,6 +117,7 @@ pub(crate) fn restore_to_oplog(
117
117
project : & Project ,
118
118
_json : bool ,
119
119
oplog_sha : & str ,
120
+ force : bool ,
120
121
) -> anyhow:: Result < ( ) > {
121
122
let snapshots = but_api:: undo:: list_snapshots ( project. id , 1000 , None , None ) ?;
122
123
@@ -160,23 +161,25 @@ pub(crate) fn restore_to_oplog(
160
161
println ! ( " Snapshot: {}" , commit_sha_string[ ..7 ] . cyan( ) . underline( ) ) ;
161
162
162
163
// Confirm the restoration (safety check)
163
- println ! (
164
- "\n {}" ,
165
- "⚠️ This will overwrite your current workspace state."
166
- . yellow( )
167
- . bold( )
168
- ) ;
169
- print ! ( "Continue with restore? [y/N]: " ) ;
170
- use std:: io:: { self , Write } ;
171
- io:: stdout ( ) . flush ( ) ?;
172
-
173
- let mut input = String :: new ( ) ;
174
- io:: stdin ( ) . read_line ( & mut input) ?;
175
-
176
- let input = input. trim ( ) . to_lowercase ( ) ;
177
- if input != "y" && input != "yes" {
178
- println ! ( "{}" , "Restore cancelled." . yellow( ) ) ;
179
- return Ok ( ( ) ) ;
164
+ if !force {
165
+ println ! (
166
+ "\n {}" ,
167
+ "⚠️ This will overwrite your current workspace state."
168
+ . yellow( )
169
+ . bold( )
170
+ ) ;
171
+ print ! ( "Continue with restore? [y/N]: " ) ;
172
+ use std:: io:: { self , Write } ;
173
+ io:: stdout ( ) . flush ( ) ?;
174
+
175
+ let mut input = String :: new ( ) ;
176
+ io:: stdin ( ) . read_line ( & mut input) ?;
177
+
178
+ let input = input. trim ( ) . to_lowercase ( ) ;
179
+ if input != "y" && input != "yes" {
180
+ println ! ( "{}" , "Restore cancelled." . yellow( ) ) ;
181
+ return Ok ( ( ) ) ;
182
+ }
180
183
}
181
184
182
185
// Restore to the target snapshot using the but-api crate
0 commit comments