-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7268 from dependabot/brrygrdn/avoid-dropping-peer…
…-manifests [Updater] Fix a bug in how we handle 'peer' manifests
- Loading branch information
Showing
8 changed files
with
4,803 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
updater/lib/dependabot/updater/group_dependency_file_batch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
# This class is responsible for tracking changes to the original files as we | ||
# make changes | ||
module Dependabot | ||
class Updater | ||
class GroupDependencyFileBatch | ||
def initialize(initial_dependency_files) | ||
@dependency_file_batch = initial_dependency_files.each_with_object({}) do |file, hash| | ||
hash[file.path] = { file: file, changed: false, changes: 0 } | ||
end | ||
|
||
Dependabot.logger.debug("Starting with '#{@dependency_file_batch.count}' dependency files:") | ||
debug_current_state | ||
end | ||
|
||
# Returns an array of DependencyFile objects for the current state | ||
def dependency_files | ||
@dependency_file_batch.map do |_path, data| | ||
data[:file] | ||
end | ||
end | ||
|
||
# Returns an array of DependencyFile objects that have changed at least once | ||
def updated_files | ||
@dependency_file_batch.filter_map do |_path, data| | ||
data[:file] if data[:changed] | ||
end | ||
end | ||
|
||
# Replaces the existing files | ||
def merge(updated_files) | ||
updated_files.each do |updated_file| | ||
existing_file = @dependency_file_batch[updated_file.path] | ||
|
||
change_count = if existing_file | ||
existing_file.fetch(:change_count, 0) | ||
else | ||
# Let's warn about this in debug mode, but otherwise tolerate this. | ||
Dependabot.logger.debug("Updated an unexpected file at '#{existing_file.path}'") | ||
0 | ||
end | ||
|
||
@dependency_file_batch[updated_file.path] = { file: updated_file, changed: true, changes: change_count + 1 } | ||
end | ||
|
||
Dependabot.logger.debug("Dependency files updated:") | ||
debug_current_state | ||
end | ||
|
||
def debug_current_state | ||
return unless Dependabot.logger.debug? | ||
|
||
@dependency_file_batch.each do |path, data| | ||
changed_string = data[:changed] ? "( Changed #{data[:changes]} times )" : "" | ||
Dependabot.logger.debug(" - #{path} #{changed_string}") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM ghcr.io/dependabot/dependabot-updater-bundler:v2.0.20230317134336@sha256:f1a76307b9a43d4d25289852e2d0ee73f1bf2bbef1a935d9255c2e56f9db64fc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM ghcr.io/dependabot/dependabot-updater-cargo:v2.0.20230317130517@sha256:8913caf469d377ae28525b184b40f61b554d839082f594b31a36beb7344d12bc |
40 changes: 40 additions & 0 deletions
40
...ter/spec/fixtures/job_definitions/docker/version_updates/group_update_peer_manifests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
job: | ||
package-manager: docker | ||
source: | ||
provider: github | ||
repo: github/dependabot-action | ||
directory: "/docker" | ||
branch: | ||
api-endpoint: https://api.github.com/ | ||
hostname: github.com | ||
commit: 302aaa943c6507c10cbbfd1b7f0fd623c5743807 | ||
dependencies: | ||
dependency-groups: | ||
- name: dependabot-core-images | ||
rules: | ||
patterns: | ||
- "dependabot/*" | ||
existing-pull-requests: [] | ||
updating-a-pull-request: false | ||
lockfile-only: false | ||
update-subdependencies: false | ||
ignore-conditions: [] | ||
requirements-update-strategy: | ||
allowed-updates: | ||
- dependency-type: direct | ||
update-type: all | ||
credentials-metadata: | ||
- type: git_source | ||
host: github.com | ||
security-advisories: [] | ||
max-updater-run-time: 2700 | ||
vendor-dependencies: false | ||
experiments: | ||
grouped-updates-prototype: true | ||
reject-external-code: false | ||
commit-message-options: | ||
prefix: | ||
prefix-development: | ||
include-scope: | ||
security-updates-only: false | ||
|
Oops, something went wrong.