@@ -230,17 +230,8 @@ def update_files
230230 updated_go_sum = original_go_sum ? File . read ( "go.sum" ) : nil
231231 updated_go_mod = File . read ( "go.mod" )
232232
233- # Restore go.sum lines that were removed for modules unrelated
234- # to the update — Go tooling can over-prune /go.mod checksums.
235233 if original_go_sum && updated_go_sum
236- graph_after = GoModGraph . capture
237- unless graph_before . empty? || graph_after . empty?
238- updated_go_sum = reconcile_go_sum (
239- original_go_sum ,
240- updated_go_sum ,
241- graph_before . changed_modules ( graph_after )
242- )
243- end
234+ updated_go_sum = reconcile_updated_go_sum ( original_go_sum , updated_go_sum , graph_before )
244235 end
245236
246237 { go_mod : updated_go_mod , go_sum : updated_go_sum }
@@ -423,6 +414,22 @@ def in_repo_path(&block)
423414 end
424415 end
425416
417+ # Captures the post-update module graph, diffs it against the
418+ # pre-update graph, and restores over-pruned go.sum lines.
419+ sig do
420+ params (
421+ original_go_sum : String ,
422+ updated_go_sum : String ,
423+ graph_before : GoModGraph
424+ ) . returns ( String )
425+ end
426+ def reconcile_updated_go_sum ( original_go_sum , updated_go_sum , graph_before )
427+ graph_after = GoModGraph . capture
428+ return updated_go_sum if graph_before . empty? || graph_after . empty?
429+
430+ reconcile_go_sum ( original_go_sum , updated_go_sum , graph_before . changed_modules ( graph_after ) )
431+ end
432+
426433 # Restores /go.mod checksum lines in go.sum that were removed for
427434 # modules unrelated to the dependency update. Go tooling can
428435 # over-prune these entries, causing CI failures downstream.
0 commit comments