Skip to content

Allow exceptions to "Allow duplicates" group setting for Maven

Related: #467254 (closed)

UI Changes

Current: We disable the Exceptions input box in the UI if Allow duplicates is toggled on.

New behavior: (only for Maven) Always keep the Exceptions input box enabled

Logic Changes

Current: If Allow duplicates is off, duplicates are not allowed except if the package name or version matches the Exceptions regexp.

New behavior: Current + If Allow duplicates is on, duplicates are allowed except if the package name or version matches the Exceptions regexp.

Implementation

To implement this, we'll need three checks:

  • 1️⃣ Does the group settings allow duplicates for Maven packages?
  • 2️⃣ Is the package a duplicate of an existing package?
  • 3️⃣ Does the package name or version match the exception regex?

We currently have 2 checks in the code:

  • The checks for 1️⃣ and 3️⃣ are in ::Namespace::PackageSetting.duplicates_allowed?(package) link to code
  • The check for 2️⃣ is in app/services/packages/maven/find_or_create_package_service.rb link to code

To make the changes smaller and easier to review, let's split the changes into two MRs:

  1. Refactor ::Namespace::PackageSetting.duplicates_allowed?(package) into two methods that do checks 1️⃣ and 3️⃣ above. That way our checks can be easily modified and reused to implement the new behavior.
  2. Implement the new behavior: If Allow duplicates is on, duplicates are allowed except if the package name or version matches the Exceptions regexp.
Edited by Radamanthus Batnag