File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,11 @@ def set_keep_when_inactive(self, keep: bool) -> bool:
250250 :return: Whether the operation was successful
251251 """
252252 log .info ("Setting %s keep when inactive to %s" , self , keep )
253+ if self .is_main ():
254+ if not keep :
255+ log .warning ("%s is main branch, can't be purgeable, skipping..." , str (self ))
256+ raise exceptions .UnsupportedOperation (f"{ str (self )} is the main branch, can't be purgeable" )
257+ return True
253258 ok = self .post ("project_branches/set_automatic_deletion_protection" , params = self .api_params () | {"value" : str (keep ).lower ()}).ok
254259 if ok :
255260 self ._keep_when_inactive = keep
@@ -285,7 +290,10 @@ def import_config(self, config_data: types.ObjectJsonRepr) -> None:
285290 log .debug ("Importing %s with %s" , str (self ), config_data )
286291 if config_data .get ("isMain" , False ):
287292 self .set_as_main ()
288- self .set_keep_when_inactive (config_data .get ("keepWhenInactive" , False ))
293+ try :
294+ self .set_keep_when_inactive (config_data .get ("keepWhenInactive" , False ))
295+ except exceptions .UnsupportedOperation as e :
296+ log .warning (e .message )
289297 if settings .NEW_CODE_PERIOD in config_data :
290298 new_code = settings .string_to_new_code (config_data [settings .NEW_CODE_PERIOD ])
291299 param = None
You can’t perform that action at this time.
0 commit comments