@@ -83,11 +83,19 @@ def main(): # pragma: no cover
8383 filename_list = [".github/dependabot.yaml" , ".github/dependabot.yml" ]
8484 dependabot_filename_to_use = filename_list [0 ] # Default to the first filename
8585 for filename in filename_list :
86- existing_config = check_existing_config (repo , filename , update_existing )
86+ existing_config = check_existing_config (repo , filename )
8787 if existing_config :
8888 dependabot_filename_to_use = filename
8989 break
9090
91+ if existing_config and not update_existing :
92+ print (
93+ "Skipping "
94+ + repo .full_name
95+ + " (dependabot file already exists and update_existing is False)"
96+ )
97+ continue
98+
9199 if created_after_date and is_repo_created_date_before (
92100 repo .created_at , created_after_date
93101 ):
@@ -207,15 +215,14 @@ def is_dependabot_security_updates_enabled(owner, repo, access_token):
207215 return False
208216
209217
210- def check_existing_config (repo , filename , update_existing ):
218+ def check_existing_config (repo , filename ):
211219 """
212220 Check if the dependabot file already exists in the
213221 repository and return the existing config if it does
214222
215223 Args:
216224 repo (github3.repos.repo.Repository): The repository to check
217225 filename (str): The dependabot configuration filename to check
218- update_existing (bool): Whether to update existing dependabot configuration files
219226
220227 Returns:
221228 github3.repos.contents.Contents | None: The existing config if it exists, otherwise None
@@ -224,14 +231,10 @@ def check_existing_config(repo, filename, update_existing):
224231 try :
225232 existing_config = repo .file_contents (filename )
226233 if existing_config .size > 0 :
227- if not update_existing :
228- print (
229- "Skipping " + repo .full_name + " (dependabot file already exists)"
230- )
231- return None
234+ return existing_config
232235 except github3 .exceptions .NotFoundError :
233236 pass
234- return existing_config
237+ return None
235238
236239
237240def enable_dependabot_security_updates (owner , repo , access_token ):
0 commit comments