Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing rebases not finding the existing pull request due to directory #10320

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions silent/tests/testdata/su-basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/depe
stderr 'created \| dependency-a \( from 1.2.3 to 1.2.4 \)'
pr-created expected.json

dependabot update -f input-rebase-old.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr 'updated \| dependency-a \( from 1.2.3 to 1.2.4 \)'
pr-updated expected.json

dependabot update -f input-rebase-new.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr 'updated \| dependency-a \( from 1.2.3 to 1.2.4 \)'
pr-updated expected.json

-- manifest.json --
{
"dependency-a": { "version": "1.2.3" },
Expand Down Expand Up @@ -55,3 +63,62 @@ job:
rules:
patterns:
- "*"

-- input-rebase-old.yml --
job:
package-manager: "silent"
dependencies:
- dependency-a
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: dependency-a
affected-versions:
- < 1.2.4
patched-versions: []
unaffected-versions: []
security-updates-only: true
# If present, groups are ignored
dependency-groups:
- name: all
rules:
patterns:
- "*"
updating-a-pull-request: true
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.4

-- input-rebase-new.yml --
job:
package-manager: "silent"
dependencies:
- dependency-a
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: dependency-a
affected-versions:
- < 1.2.4
patched-versions: []
unaffected-versions: []
security-updates-only: true
# If present, groups are ignored
dependency-groups:
- name: all
rules:
patterns:
- "*"
updating-a-pull-request: true
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.4
directory: "/"
25 changes: 23 additions & 2 deletions silent/tests/testdata/vu-basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/depe
stderr 'created \| dependency-a \( from 1.2.3 to 1.2.5 \)'
pr-created expected.json

dependabot update -f input-2.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
dependabot update -f input-rebase-old.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr 'updated \| dependency-a \( from 1.2.3 to 1.2.5 \)'
pr-updated expected.json

dependabot update -f input-rebase-new.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr 'updated \| dependency-a \( from 1.2.3 to 1.2.5 \)'
pr-updated expected.json

Expand Down Expand Up @@ -35,7 +39,23 @@ job:
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests

-- input-2.yml --
-- input-rebase-old.yml --
job:
package-manager: "silent"
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
dependencies:
- dependency-a
updating-a-pull-request: true
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.5

-- input-rebase-new.yml --
job:
package-manager: "silent"
source:
Expand All @@ -50,3 +70,4 @@ job:
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.5
directory: "/"
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ def log_requirements_for_update(requirements_to_unlock, checker)
end

def existing_pull_request(updated_dependencies)
new_pr_set = Set.new(
updated_dependencies.map do |dep|
{
"dependency-name" => dep.name,
"dependency-version" => dep.version,
"dependency-removed" => dep.removed? ? true : nil,
"directory" => dep.directory
}.compact
end
)

existing = job.existing_pull_requests.find { |pr| Set.new(pr) == new_pr_set }
return existing if existing

# try the search again without directory
new_pr_set = Set.new(
updated_dependencies.map do |dep|
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ def log_requirements_for_update(requirements_to_unlock, checker)
end

def existing_pull_request(updated_dependencies)
new_pr_set = Set.new(
updated_dependencies.map do |dep|
{
"dependency-name" => dep.name,
"dependency-version" => dep.version,
"dependency-removed" => dep.removed? ? true : nil,
"directory" => dep.directory
}.compact
end
)

existing = job.existing_pull_requests.find { |pr| Set.new(pr) == new_pr_set }
return existing if existing

# try the search again without directory
new_pr_set = Set.new(
updated_dependencies.map do |dep|
{
Expand Down
Loading