Skip to content

Console error when replace/delete files from past commit

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When attempting to replace or delete file in a past commit, we've got an error in the console.

Current Behavior

  1. Errors occur when:
    • Use the ref selector to open a file from a past commit
    • Click history => Navigate back with browser back button
    • OR Click blame => Navigate back with breadcrumb
    • Or Click blame => Permalink
  2. Console errors appear && user sees a message about forking the project Jan_16_2025_Screenshot

Expected behaviour

There should not be console errors.

Implementation Plan

  • We pass down target_branch from blob_content_viewer to blob_button_group for delete (ref) and replace (ref) blob
  • In a nutshell, this check on_top_of_branch fails and we won't get a value from the helper.
  • Guard the check with optional chaining
  • note, This behaviour weren't changed by the commit change blob work recently. I was able to verify by checking out this commit (prior to switching replace blob to the modal), it has the same behaviour.
Edited by 🤖 GitLab Bot 🤖