-
Stan Hu authored
Fix 404 error in files view after deleting the last file in a repository Here's the logic: 1. In `TreeController`, `require_non_empty_project` will prevent `show` from being called if the project is empty. That means all calls to `show` will be guaranteed to have at least 1 commit. 2. If the ref name is not valid, then return a 404. This ensures that at least the controller is looking at a valid branch/tag/SHA ID. 3. This leaves a number of cases: ``` 3a. Valid ref, valid directory 3b. Valid ref, valid filename 3c. Valid ref, invalid path 3d. Valid ref, no files ``` Case 3a: The tree will not be `empty?` and will pass through the whole function. Case 3b: The tree will be `empty?` but the `blob_at` will resolve properly and trigger a redirect to the file. Case 3c: In this case, a path is given. Return 404 if it cannot be resolved neither as a tree nor a blob. Case 3d: In this case, no path is given. If the tree is empty, this means it's an empty branch and just fall through. Example broken branch: https://gitlab.com/gitlab-org/gitlab-test/tree/empty-branch Closes #1362 See merge request !1010
f593b621
To find the state of this project's repository at the time of any of these versions, check out
the tags.