@@ -83,11 +83,19 @@ def main(): # pragma: no cover
83
83
filename_list = [".github/dependabot.yaml" , ".github/dependabot.yml" ]
84
84
dependabot_filename_to_use = filename_list [0 ] # Default to the first filename
85
85
for filename in filename_list :
86
- existing_config = check_existing_config (repo , filename , update_existing )
86
+ existing_config = check_existing_config (repo , filename )
87
87
if existing_config :
88
88
dependabot_filename_to_use = filename
89
89
break
90
90
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
+
91
99
if created_after_date and is_repo_created_date_before (
92
100
repo .created_at , created_after_date
93
101
):
@@ -207,15 +215,14 @@ def is_dependabot_security_updates_enabled(owner, repo, access_token):
207
215
return False
208
216
209
217
210
- def check_existing_config (repo , filename , update_existing ):
218
+ def check_existing_config (repo , filename ):
211
219
"""
212
220
Check if the dependabot file already exists in the
213
221
repository and return the existing config if it does
214
222
215
223
Args:
216
224
repo (github3.repos.repo.Repository): The repository to check
217
225
filename (str): The dependabot configuration filename to check
218
- update_existing (bool): Whether to update existing dependabot configuration files
219
226
220
227
Returns:
221
228
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):
224
231
try :
225
232
existing_config = repo .file_contents (filename )
226
233
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
232
235
except github3 .exceptions .NotFoundError :
233
236
pass
234
- return existing_config
237
+ return None
235
238
236
239
237
240
def enable_dependabot_security_updates (owner , repo , access_token ):
0 commit comments