@@ -168,25 +168,29 @@ async fn generate_ai_commit_message(
168168}
169169
170170#[ tauri:: command]
171- async fn preview_alias ( request : AliasRequest ) -> Result < String , String > {
171+ async fn preview_alias (
172+ alias_name : String ,
173+ commands : Vec < GitCommand > ,
174+ ai_commit : bool ,
175+ openai_api_key : Option < String > ,
176+ ) -> Result < String , String > {
172177 let mut command_parts = Vec :: new ( ) ;
173178
174- for cmd in & request . commands {
179+ for cmd in & commands {
175180 if cmd. enabled {
176181 match cmd. name . as_str ( ) {
177182 "add" => command_parts. push ( "git add ." . to_string ( ) ) ,
178183 "commit" => {
179184 let message = cmd. parameters . get ( "message" ) . unwrap_or ( & "WIP" . to_string ( ) ) . clone ( ) ;
180- if request . ai_commit {
185+ if ai_commit {
181186 command_parts. push ( "echo 'Getting AI-generated commit message...'" . to_string ( ) ) ;
182187 command_parts. push ( "git commit -m \" $(echo 'AI message would be generated here')\" " . to_string ( ) ) ;
183188 } else {
184189 command_parts. push ( format ! ( "git commit -m \" {}\" " , message) ) ;
185190 }
186191 } ,
187192 "push" => {
188- let branch = cmd. parameters . get ( "branch" ) . unwrap_or ( & "origin" . to_string ( ) ) . clone ( ) ;
189- command_parts. push ( format ! ( "git push {}" , branch) ) ;
193+ command_parts. push ( "git push" . to_string ( ) ) ;
190194 } ,
191195 "checkout" => {
192196 let branch = cmd. parameters . get ( "branch" ) . unwrap_or ( & "$1" . to_string ( ) ) . clone ( ) ;
@@ -215,9 +219,14 @@ async fn preview_alias(request: AliasRequest) -> Result<String, String> {
215219}
216220
217221#[ tauri:: command]
218- async fn create_alias ( request : AliasRequest ) -> AliasResponse {
222+ async fn create_alias (
223+ alias_name : String ,
224+ commands : Vec < GitCommand > ,
225+ ai_commit : bool ,
226+ openai_api_key : Option < String > ,
227+ ) -> AliasResponse {
219228 // First validate the alias name
220- let validation = validate_alias_name ( request . alias_name . clone ( ) ) . await ;
229+ let validation = validate_alias_name ( alias_name. clone ( ) ) . await ;
221230 if !validation. valid {
222231 return AliasResponse {
223232 success : false ,
@@ -227,7 +236,12 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
227236 }
228237
229238 // Generate the alias command
230- let alias_command = match preview_alias ( request. clone ( ) ) . await {
239+ let alias_command = match preview_alias (
240+ alias_name. clone ( ) ,
241+ commands. clone ( ) ,
242+ ai_commit,
243+ openai_api_key. clone ( ) ,
244+ ) . await {
231245 Ok ( cmd) => cmd,
232246 Err ( e) => {
233247 return AliasResponse {
@@ -243,7 +257,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
243257 . args ( & [
244258 "config" ,
245259 "--global" ,
246- & format ! ( "alias.{}" , request . alias_name) ,
260+ & format ! ( "alias.{}" , alias_name) ,
247261 & alias_command,
248262 ] )
249263 . output ( ) ;
@@ -256,7 +270,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
256270 . args ( & [
257271 "config" ,
258272 "--global" ,
259- & format ! ( "alias-tool.{}" , request . alias_name) ,
273+ & format ! ( "alias-tool.{}" , alias_name) ,
260274 "git-alias-generator" ,
261275 ] )
262276 . output ( ) ;
@@ -268,7 +282,7 @@ async fn create_alias(request: AliasRequest) -> AliasResponse {
268282
269283 AliasResponse {
270284 success : true ,
271- message : format ! ( "Alias '{}' created successfully!" , request . alias_name) ,
285+ message : format ! ( "Alias '{}' created successfully!" , alias_name) ,
272286 alias_command : Some ( alias_command) ,
273287 }
274288 } else {
0 commit comments