@@ -16,9 +16,9 @@ fn get_zip_file_path() -> PathBuf {
1616 dst_file
1717}
1818#[ tracing:: instrument]
19- pub fn commit ( ) {
19+ pub fn commit ( teams : bool ) {
2020 let token = super :: expect_token ( ) ;
21- let app_id = match super :: ask_for_app ( token. clone ( ) , "commit" ) {
21+ let app_id = match super :: ask_for_app ( token. clone ( ) , "commit" , teams ) {
2222 Ok ( app_id) => app_id,
2323 Err ( error) => {
2424 super :: err ( & format ! ( "Couldn't fetch apps: {}" , error) ) ;
@@ -33,8 +33,8 @@ pub fn commit() {
3333 Err ( e) => super :: err ( & format ! ( "Failed to zip: {:?}" , e) ) ,
3434 }
3535 let mut spinner = Spinner :: new ( spinners:: Spinners :: Earth , "Committing app..." . to_string ( ) ) ;
36- let msg = match upload_zip ( token, app_id) {
37- Ok ( ( ) ) => super :: format_log ( "Your app was successfully commited !" ) ,
36+ let msg = match upload_zip ( token, app_id, teams ) {
37+ Ok ( ( ) ) => if !teams { super :: format_log ( "Your app was updated successfully!" ) } else { super :: format_log ( "Your buddy's app was updated !") } ,
3838 Err ( err) => super :: format_err ( & err) ,
3939 } ;
4040 spinner. stop_with_message ( msg) ;
@@ -115,7 +115,7 @@ fn zip_dir_to_file(
115115 Ok ( ( ) )
116116}
117117#[ tracing:: instrument]
118- fn upload_zip ( token : String , app_id : u128 ) -> Result < ( ) , String > {
118+ fn upload_zip ( token : String , app_id : u128 , teams : bool ) -> Result < ( ) , String > {
119119 let file_path = get_zip_file_path ( ) ;
120120 let file_path = file_path. to_str ( ) . unwrap ( ) ;
121121 let client = reqwest:: blocking:: Client :: builder ( )
@@ -127,7 +127,7 @@ fn upload_zip(token: String, app_id: u128) -> Result<(), String> {
127127 Err ( err) => Err ( format ! ( "Couldn't open zip file: {}" , err) ) ,
128128 Ok ( form) => {
129129 let req = client
130- . put ( crate :: api_url!( format!( "/app /{}/commit" , app_id) ) )
130+ . put ( crate :: api_url!( format!( "/{} /{}/commit" , if teams { "team" } else { "app" } , app_id) ) )
131131 . multipart ( form)
132132 . header ( "api-token" , token) ;
133133 let res = req. send ( ) ;
0 commit comments