Skip to content

Handle "All branches" and "All protected branches"

What does this MR do and why?

  • Allows to "create" All protected branches and All branches rules by bypassing modal and going from the dropdown straight to details page. Note: The rule is saved only after any rule details are specified (like adding merge request approval rules or status checks)
  • Hides sections irrelevant to these two rules, leaving only Rule target, Merge request approvals and Status checks visible
  • Disables option for editing Rule target. For these two rules we want it to stay either All protected branches or All branches
  • Entering a details page for a rule that doesn't exist shows No data to display, while entering details page for All protected branches or All branches via url and not UI should still render all applicable sections
  • Refactored unit tests - moving a bunch of single it blocks to be first, followed by describe blocks grouping specific actions or component data.

Note: We don't have yet the feature rspec for Branch rule details page. Since this MR is already quite lengthy, I'll address that in a separate MR. The same goes for documentation.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Context Before After
Creating a rule for All branches or All protected branches in Settings / Repository (not possible) Screenshot_2024-04-18_at_10.32.39 Screen_Recording_2024-04-18_at_10.25.56
Creating a MR approval rules for All branches or All protected branches vie Settings / Merge Requests Screen_Recording_2024-04-18_at_10.33.42 Screen_Recording_2024-04-18_at_10.27.19

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

I recommend reviewing in IDE by downloading the diff from MR and dumping it onto master branch. If reviewing in the MR, you'll get cleaner diff by not showing whitespace changes.

  1. Open Rails console. In your terminal: rails c
  2. Enable the feature flag:
Feature.enable(:edit_branch_rules)
  1. In a project, go to Settings / Repository
  2. Expand Branch rules section
  3. Click on Add branch rule and select All branches. You should be redirected to a details page.
  4. Do not change anything, go back to previous Repository settings page. All branches should not be visible on Branch rules listing.
  5. Repeat step 4.
  6. When on details page, add approval rule in Merge request approvals section (a drawer will open allowing you to choose different approvers).
  7. Go back to previous Repository settings page. This time All branches should be visible on Branch rules listing and not available in the Add branch rule* dropdown.
  8. Paste in your browser this url (changing localhost address if needed): http://gdk.test:8080/flightjs/Flight/-/settings/repository/branch_rules?branch=All%20protected%20branches - this should allow you to create a rule for All protected branches. You can repeat step 7.
  9. Paste in your browser this url (changing localhost address if needed): http://gdk.test:8080/flightjs/Flight/-/settings/repository/branch_rules?branch=My%20new%20branch%20rule%20that%20doesnt%20exist - this should give you an empty state.
  10. Delete a rule. Go to Settings / Merge Requests and scroll down to Merge Request Approvals.
  11. Set a MR approval rule for previously deleted rule (see the recording above).
  12. Navigate back to Settings / Repository Branch rules. You should see a rule created based on MR approval you set in step 12.

Related to #388129

Edited by Paulina Sedlak-Jakubowska

Merge request reports