Skip to content

Draft: Resolve "Files not tracked with LFS when uploaded through the web interface"

What does this MR do and why?

This MR needs Fix bug where create MR toggle wasn't inspected... (!139047 - merged) merged first.

This MR fixes a bug where a create new file / file upload that matches the list of LFS files to track (e.g. a .pdf file) isn't registered as an LFS file in the new branch. The core of the bug is that when creating a new file for a branch that doesn't yet exist, the logic is unable to determine which files should be LFS trackable and so assumes it shouldn't LFS tracked.

The solution here is to create the branch before we attempt to create the file. The new branch is created based off the branch the user was sitting within when they requested a new file to be created which will include the all important .gitattributes file.

How to set up and validate locally

Referencing #326342 (closed):

  1. Set up a project with a repository with LFS enabled.
  2. Set up LFS tracking for at least one file, e.g. git lfs track "*.pdf".
  3. Commit and push so that .gitattributes is visible in the master branch in the web interface.
  4. Invite a user as Developer.
  5. As this user, open the project (you see the master branch), click "+" and "Upload file". Leave default values and upload a file matching the LFS pattern specified in step (2), e.g. lfs-test.pdf.
  6. Check the newly (and automatically) created branch. The uploaded file is not tracked with LFS.
  7. Cross-check: create a branch manually and upload the file here the same way. It is tracked with LFS as expected.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #326342 (closed)

Edited by Ash McKenzie

Merge request reports