@@ -373,7 +373,7 @@ def audit(self, settings: types.ConfigSettings = None) -> list[Problem]:
373373 problems .append (Problem (get_rule (RuleId .USER_UNUSED ), self , str (self ), age ))
374374 return problems
375375
376- def to_json (self , full : bool = False ) -> types .ObjectJsonRepr :
376+ def to_json (self , export_settings : types . ConfigSettings ) -> types .ObjectJsonRepr :
377377 """Exports the user data (login, email, groups, SCM accounts local or not) as dict
378378
379379 :return: User data
@@ -382,13 +382,15 @@ def to_json(self, full: bool = False) -> types.ObjectJsonRepr:
382382 json_data = self ._json .copy ()
383383 scm = self .scm_accounts
384384 json_data ["scmAccounts" ] = util .list_to_csv (scm ) if scm else None
385- my_groups = self .groups ().copy ()
386- if "sonar-users" in my_groups :
387- my_groups .remove ("sonar-users" )
388- json_data ["groups" ] = util .list_to_csv (my_groups , ", " , True )
389- if not self .endpoint .is_sonarcloud () and not full and not json_data ["local" ]:
385+ json_data ["groups" ] = self .groups ().copy ()
386+ if export_settings .get ("MODE" , "" ) == "MIGRATION" :
387+ return json_data
388+ if "sonar-users" in json_data ["groups" ]:
389+ json_data ["groups" ].remove ("sonar-users" )
390+
391+ if not self .endpoint .is_sonarcloud () and not export_settings ["FULL_EXPORT" ] and not json_data ["local" ]:
390392 json_data .pop ("local" )
391- return util .remove_nones (util .filter_export (json_data , SETTABLE_PROPERTIES , full ))
393+ return util .remove_nones (util .filter_export (json_data , SETTABLE_PROPERTIES , export_settings [ "FULL_EXPORT" ] ))
392394
393395
394396def search (endpoint : pf .Platform , params : types .ApiParams = None ) -> dict [str , User ]:
@@ -415,7 +417,7 @@ def export(endpoint: pf.Platform, export_settings: types.ConfigSettings, key_lis
415417 log .info ("Exporting users" )
416418 u_list = {}
417419 for u_login , u_obj in sorted (search (endpoint = endpoint ).items ()):
418- u_list [u_login ] = u_obj .to_json (export_settings [ "FULL_EXPORT" ] )
420+ u_list [u_login ] = u_obj .to_json (export_settings )
419421 u_list [u_login ].pop ("login" , None )
420422 return u_list
421423
0 commit comments