Persist committed changes when switching branches in the pipeline editor

Summary

When switching between branches on the pipeline editor using the branch switcher, changes are not persisted. Switching away from a branch, then switching back to it, discards your changes and shows the config as it was when you first loaded the page. This happens to both committed and non-committed changes. This issue addresses the more severe of the two, committed changes. Uncommitted changes will be fixed in #331107 (closed)

Steps to reproduce

  1. Enable the pipeline_editor_branch_switcher feature flag (this is currently on for gitlab.com)
  2. Open the pipeline editor on a project with a .gitlab-ci.yaml file.
  3. Make some changes to the config file and commit those changes to a new branch.
  4. This is the first point of failure, the new branch isn't available in the switcher. Until you…
  5. refresh the page and select the branch you just created from the switcher.
  6. Make some changes to that branch and commit them.
  7. Switch away from that branch
  8. switch back to that branch. Your changes will have dissapeared.

Here's an example video of me encountering the problem. test_f

Example Project

This project already has the feature flag enabled and is specifically set up to test issues like this. Please feel free to (ab)use it as needed to test this feature.

https://gitlab.com/samdbeckham/test

What is the current bug behavior?

When switching between branches, committed changes are not persisted in the UI.

What is the expected correct behavior?

When switching between branches, the most up-to-date version of that branch should be shown.

Possible fixes

Update the cache when committing changes. This keeps the performance benefits of only requesting the data when nessesary and fixes both the new branch problem and the persistant changes problem in one fell swoop.

Edited by Sam Beckham