@@ -276,7 +276,7 @@ def create_upload_job(
276276 return job
277277
278278
279- def push_project_async (mc , directory , check_version = False ) -> Optional [UploadJob ]:
279+ def push_project_async (mc , directory ) -> Optional [UploadJob ]:
280280 """Starts push of a project and returns pending upload job"""
281281
282282 mp = MerginProject (directory )
@@ -289,34 +289,10 @@ def push_project_async(mc, directory, check_version=False) -> Optional[UploadJob
289289 mp .log .info ("--- version: " + mc .user_agent_info ())
290290 mp .log .info (f"--- start push { project_path } " )
291291
292- try :
293- project_info = mc .project_info (project_path )
294- except ClientError as err :
295- mp .log .error ("Error getting project info: " + str (err ))
296- mp .log .info ("--- push aborted" )
297- raise
298- server_version = project_info ["version" ] if project_info ["version" ] else "v0"
299-
300- mp .log .info (f"got project info: local version { local_version } / server version { server_version } " )
301-
302- username = mc .username ()
303- # permissions field contains information about update, delete and upload privileges of the user
304- # on a specific project. This is more accurate information then "writernames" field, as it takes
305- # into account namespace privileges. So we have to check only "permissions", namely "upload" one
306- if not mc .has_writing_permissions (project_path ):
307- mp .log .error (f"--- push { project_path } - username { username } does not have write access" )
308- raise ClientError (f"You do not seem to have write access to the project (username '{ username } ')" )
309-
310- # DISCUSSION: do we want to check if the project is up to date before pushing? For now, we removed this part
311- if check_version and local_version != server_version :
312- mp .log .error (f"--- push { project_path } - not up to date (local { local_version } vs server { server_version } )" )
313- raise ClientError (
314- "There is a new version of the project on the server. Please update your local copy."
315- + f"\n \n Local version: { local_version } \n Server version: { server_version } "
316- )
292+ mp .log .info (f"got project info: local version { local_version } " )
317293
318294 tmp_dir = tempfile .TemporaryDirectory (prefix = "python-api-client-" )
319- changes , changes_len = get_push_changes_batch (mc , mp , project_info )
295+ changes , changes_len = get_push_changes_batch (mc , mp )
320296 if not changes_len :
321297 mp .log .info (f"--- push { project_path } - nothing to do" )
322298 return
@@ -489,11 +465,12 @@ def remove_diff_files(job: UploadJob) -> None:
489465 os .remove (diff_file )
490466
491467
492- def get_push_changes_batch (mc , mp : MerginProject , project_info : dict ) -> Tuple [dict , int ]:
468+ def get_push_changes_batch (mc , mp : MerginProject ) -> Tuple [dict , int ]:
493469 """
494470 Get changes that need to be pushed to the server.
495471 """
496472 changes = mp .get_push_changes ()
497- changes = filter_changes (mc , project_info , changes )
473+ project_role = mp .project_role ()
474+ changes = filter_changes (mc , project_role , changes )
498475
499476 return changes , sum (len (v ) for v in changes .values ())
0 commit comments