gitlab-org--gitlab-foss/app
Stan Hu f593b621e3 Merge branch 'fix-404-empty-repo' into 'master'
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
2015-07-22 01:01:03 +00:00
..
assets Fix full screen mode for snippet comments 2015-07-21 19:51:16 +02:00
controllers Fix 404 error in files view after deleting the last file in a repository 2015-07-21 14:12:43 -07:00
finders Rename NoMilestone to Milestone::None 2015-07-06 22:39:55 -04:00
helpers Fix label read access for unauthenticated users 2015-07-19 21:33:21 +02:00
mailers
models Merge branch 'fix-disabled-feature-access' into 'master' 2015-07-20 16:42:07 +00:00
services Store commit count in project table 2015-07-17 15:22:56 +02:00
uploaders
views Merge branch 'mr-fetch-command' into 'master' 2015-07-20 16:40:24 +00:00
workers Avoid cache building for super-weird case when repository root_ref is nil 2015-07-17 16:03:38 +02:00