Skip to content

Commit

Permalink
Dependency order isn't a factor
Browse files Browse the repository at this point in the history
  • Loading branch information
brrygrdn committed Jun 12, 2023
1 parent 119bc99 commit 75fc988
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def group_name_with_dependency_digest
def dependency_digest
@dependency_digest ||= Digest::MD5.hexdigest(dependencies.map do |dependency|
"#{dependency.name}-#{dependency.removed? ? 'removed' : dependency.version}"
end.join(",")).slice(0, 10)
end.sort.join(",")).slice(0, 10)
end

def package_manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
expect(new_namer.new_branch_name).to eql(branch_name)
end

it "generates a different branch name for a diffset set of dependencies for the same group" do
it "generates a different branch name for a different set of dependencies for the same group" do
removed_dependency = Dependabot::Dependency.new(
name: "old_business",
version: "1.4.0",
Expand All @@ -84,6 +84,36 @@
)
expect(new_namer.new_branch_name).not_to eql(namer.new_branch_name)
end

it "generates the same branch name regardless of the order of dependencies" do
removed_dependency = Dependabot::Dependency.new(
name: "old_business",
version: "1.4.0",
previous_version: "1.4.0",
package_manager: "bundler",
requirements: {},
previous_requirements: {},
removed: true
)

forward_namer = described_class.new(
dependencies: [dependency, removed_dependency],
files: [gemfile],
target_branch: target_branch,
separator: separator,
dependency_group: dependency_group
)

backward_namer = described_class.new(
dependencies: [removed_dependency, dependency],
files: [gemfile],
target_branch: target_branch,
separator: separator,
dependency_group: dependency_group
)

expect(forward_namer.new_branch_name).to eql(backward_namer.new_branch_name)
end
end

context "with a custom separator" do
Expand Down

0 comments on commit 75fc988

Please sign in to comment.