@@ -28,15 +28,14 @@ def git(*args)
28
28
ruby_version = ".ruby-version"
29
29
rubocop_yaml = ".rubocop.yml"
30
30
vale_ini = ".vale.ini"
31
+ dependabot_template_yaml = ".github/actions/sync/dependabot.template.yml"
31
32
dependabot_yaml = ".github/dependabot.yml"
32
33
docs_workflow_yaml = ".github/workflows/docs.yml"
33
34
actionlint_workflow_yaml = ".github/workflows/actionlint.yml"
34
35
stale_issues_workflow_yaml = ".github/workflows/stale-issues.yml"
35
36
zizmor_yml = ".github/zizmor.yml"
36
37
codeql_extensions_homebrew_actions_yml = ".github/codeql/extensions/homebrew-actions.yml"
37
38
38
- target_gemfile_lock = target_directory_path /"Gemfile.lock"
39
-
40
39
homebrew_docs = homebrew_repository_path /docs
41
40
homebrew_ruby_version =
42
41
( homebrew_repository_path /"Library/Homebrew/vendor/portable-ruby-version" ) . read
@@ -63,19 +62,37 @@ def git(*args)
63
62
homebrew_docs_workflow_yaml = homebrew_repository_path /docs_workflow_yaml
64
63
homebrew_vale_ini = homebrew_repository_path /vale_ini
65
64
66
- dependabot_config_yaml = YAML . load_file ( dependabot_yaml )
65
+ target_gemfile_locks = [ ]
66
+ dependabot_config_yaml = YAML . load_file ( dependabot_template_yaml )
67
67
dependabot_config_yaml [ "updates" ] = dependabot_config_yaml [ "updates" ] . filter_map do |update |
68
- keep_update = case update [ "package-ecosystem" ]
68
+ bundler_ecosystem = false
69
+ ecosystem_file = case update [ "package-ecosystem" ]
69
70
when "bundler"
70
- target_gemfile_lock . exist?
71
+ bundler_ecosystem = true
72
+ "Gemfile.lock"
71
73
when "npm"
72
- ( target_directory_path / "package.json" ) . exist?
74
+ "package.json"
73
75
when "docker"
74
- ( target_directory_path / "Dockerfile" ) . exist?
76
+ "Dockerfile"
75
77
when "devcontainers"
76
- ( target_directory_path / ".devcontainer/devcontainer.json" ) . exist?
78
+ ".devcontainer/devcontainer.json"
77
79
when "pip"
78
- ( target_directory_path /"requirements.txt" ) . exist?
80
+ "requirements.txt"
81
+ end
82
+
83
+ keep_update = if ecosystem_file && ( update_directories = update [ "directories" ] )
84
+ update_directories . select! do |directory |
85
+ ecosystem_file_path = ( target_directory_path /".#{ directory } /#{ ecosystem_file } " )
86
+ next unless ecosystem_file_path . exist?
87
+
88
+ target_gemfile_locks << ecosystem_file_path if bundler_ecosystem
89
+
90
+ true
91
+ end
92
+ update [ "directories" ] = update_directories
93
+ update_directories . any?
94
+ elsif ( update_directory = update . fetch ( "directory" ) )
95
+ ( target_directory_path /".#{ update_directory } /#{ ecosystem_file } " ) . exist?
79
96
else
80
97
true
81
98
end
@@ -161,7 +178,7 @@ def git(*args)
161
178
"# This file is synced from `Homebrew/brew` by the `.github` repository, do not modify it directly.\n " \
162
179
"#{ homebrew_docs_rubocop_config } \n " ,
163
180
)
164
- else
181
+ elsif docs_path != target_docs_path
165
182
FileUtils . cp docs_path , target_docs_path
166
183
end
167
184
end
@@ -202,14 +219,14 @@ def git(*args)
202
219
)
203
220
when dependabot_yaml , actionlint_workflow_yaml , stale_issues_workflow_yaml ,
204
221
zizmor_yml , codeql_extensions_homebrew_actions_yml
205
- next if path == target_path . to_s
206
-
207
- # ensure we don't replace the template files in this repository
208
- next if repository_name == ".github"
209
-
210
222
contents = if path == dependabot_yaml
211
223
dependabot_config
212
224
else
225
+ next if path == target_path . to_s
226
+
227
+ # ensure we don't replace the non-dependabot template files in this repository
228
+ next if repository_name == ".github"
229
+
213
230
Pathname ( path ) . read
214
231
. chomp
215
232
end
@@ -233,18 +250,19 @@ def git(*args)
233
250
# Update Gemfile.lock if it exists, based on the Ruby version.
234
251
#
235
252
# We don't have Homebrew exclude? method here.
236
- # rubocop:disable Homebrew/NegateInclude
237
- if !custom_ruby_version_repos . include? ( repository_name ) && target_gemfile_lock . exist?
238
- Dir . chdir target_directory_path do
239
- require "bundler"
240
- bundler_version = Bundler ::Definition . build ( homebrew_gemfile , homebrew_gemfile_lock , false )
241
- . locked_gems
242
- . bundler_version
243
- puts "Running bundle update (with Bundler #{ bundler_version } )..."
244
- system "bundle" , "update" , "--ruby" , "--bundler=#{ bundler_version } " , "--quiet" , out : "/dev/null"
253
+ unless custom_ruby_version_repos . include? ( repository_name )
254
+ target_gemfile_locks . each do |target_gemfile_lock |
255
+ target_directory_path = target_gemfile_lock . dirname
256
+ Dir . chdir target_directory_path do
257
+ require "bundler"
258
+ bundler_version = Bundler ::Definition . build ( homebrew_gemfile , homebrew_gemfile_lock , false )
259
+ . locked_gems
260
+ . bundler_version
261
+ puts "Running bundle update (with Bundler #{ bundler_version } )..."
262
+ system "bundle" , "update" , "--ruby" , "--bundler=#{ bundler_version } " , "--quiet" , out : "/dev/null"
263
+ end
245
264
end
246
265
end
247
- # rubocop:enable Homebrew/NegateInclude
248
266
249
267
out , err , status = Open3 . capture3 ( "git" , "-C" , target_directory , "status" , "--porcelain" , "--ignore-submodules=dirty" )
250
268
raise err unless status . success?
0 commit comments