Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
643557da
Commit
643557da
authored
Jul 20, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 404 error in files view after deleting the last file in a repository
Closes #1362
parent
57f9a1cc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
8 deletions
+46
-8
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/tree_controller.rb
app/controllers/projects/tree_controller.rb
+3
-1
spec/controllers/projects/tree_controller_spec.rb
spec/controllers/projects/tree_controller_spec.rb
+26
-3
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+8
-1
spec/support/test_env.rb
spec/support/test_env.rb
+8
-3
No files found.
CHANGELOG
View file @
643557da
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
v 7.14.0 (unreleased)
- Fix 404 error in files view after deleting the last file in a repository (Stan Hu)
- Remove repository graph log to fix slow cache updates after push event (Stan Hu)
- Remove repository graph log to fix slow cache updates after push event (Stan Hu)
- Fix label read access for unauthenticated users (Daniel Gerhardt)
- Fix label read access for unauthenticated users (Daniel Gerhardt)
- Fix access to disabled features for unauthenticated users (Daniel Gerhardt)
- Fix access to disabled features for unauthenticated users (Daniel Gerhardt)
...
...
app/controllers/projects/tree_controller.rb
View file @
643557da
...
@@ -7,13 +7,15 @@ class Projects::TreeController < Projects::ApplicationController
...
@@ -7,13 +7,15 @@ class Projects::TreeController < Projects::ApplicationController
before_action
:authorize_download_code!
before_action
:authorize_download_code!
def
show
def
show
return
not_found!
unless
@repository
.
commit
(
@ref
)
if
tree
.
entries
.
empty?
if
tree
.
entries
.
empty?
if
@repository
.
blob_at
(
@commit
.
id
,
@path
)
if
@repository
.
blob_at
(
@commit
.
id
,
@path
)
redirect_to
(
redirect_to
(
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
File
.
join
(
@ref
,
@path
))
File
.
join
(
@ref
,
@path
))
)
and
return
)
and
return
els
e
els
if
@path
.
present?
return
not_found!
return
not_found!
end
end
end
end
...
...
spec/controllers/tree_controller_spec.rb
→
spec/controllers/
projects/
tree_controller_spec.rb
View file @
643557da
...
@@ -8,9 +8,6 @@ describe Projects::TreeController do
...
@@ -8,9 +8,6 @@ describe Projects::TreeController do
sign_in
(
user
)
sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
allow
(
project
).
to
receive
(
:branches
).
and_return
([
'master'
,
'foo/bar/baz'
])
allow
(
project
).
to
receive
(
:tags
).
and_return
([
'v1.0.0'
,
'v2.0.0'
])
controller
.
instance_variable_set
(
:@project
,
project
)
controller
.
instance_variable_set
(
:@project
,
project
)
end
end
...
@@ -44,6 +41,32 @@ describe Projects::TreeController do
...
@@ -44,6 +41,32 @@ describe Projects::TreeController do
let
(
:id
)
{
'invalid-branch/encoding/'
}
let
(
:id
)
{
'invalid-branch/encoding/'
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
end
end
context
"valid empty branch, invalid path"
do
let
(
:id
)
{
'empty-branch/invalid-path/'
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
end
context
"valid empty branch"
do
let
(
:id
)
{
'empty-branch'
}
it
{
is_expected
.
to
respond_with
(
:success
)
}
end
context
"invalid SHA commit ID"
do
let
(
:id
)
{
'ff39438/.gitignore'
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
end
context
"valid SHA commit ID"
do
let
(
:id
)
{
'6d39438'
}
it
{
is_expected
.
to
respond_with
(
:success
)
}
end
context
"valid SHA commit ID with path"
do
let
(
:id
)
{
'6d39438/.gitignore'
}
it
{
expect
(
response
.
status
).
to
eq
(
302
)
}
end
end
end
describe
'GET show with blob path'
do
describe
'GET show with blob path'
do
...
...
spec/requests/api/branches_spec.rb
View file @
643557da
...
@@ -13,11 +13,18 @@ describe API::API, api: true do
...
@@ -13,11 +13,18 @@ describe API::API, api: true do
let!
(
:branch_sha
)
{
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
}
let!
(
:branch_sha
)
{
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
}
describe
"GET /projects/:id/repository/branches"
do
describe
"GET /projects/:id/repository/branches"
do
before
do
# Ensure that repository.branch_names is cleared from the cache at start to ensure
# the list matches reality
Rails
.
cache
.
clear
end
it
"should return an array of project branches"
do
it
"should return an array of project branches"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project
.
repository
.
branch_names
.
first
)
branch_names
=
json_response
.
map
{
|
x
|
x
[
'name'
]
}
expect
(
branch_names
).
to
match_array
(
project
.
repository
.
branch_names
)
end
end
end
end
...
...
spec/support/test_env.rb
View file @
643557da
...
@@ -5,6 +5,7 @@ module TestEnv
...
@@ -5,6 +5,7 @@ module TestEnv
# When developing the seed repository, comment out the branch you will modify.
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA
=
{
BRANCH_SHA
=
{
'empty-branch'
=>
'7efb185'
,
'flatten-dir'
=>
'e56497b'
,
'flatten-dir'
=>
'e56497b'
,
'feature'
=>
'0b4bc9a'
,
'feature'
=>
'0b4bc9a'
,
'feature_conflict'
=>
'bb5206f'
,
'feature_conflict'
=>
'bb5206f'
,
...
@@ -14,9 +15,13 @@ module TestEnv
...
@@ -14,9 +15,13 @@ module TestEnv
'master'
=>
'5937ac0'
'master'
=>
'5937ac0'
}
}
FORKED_BRANCH_SHA
=
BRANCH_SHA
.
merge
({
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
'add-submodule-version-bump'
=>
'3f547c08'
# need to keep all the branches in sync.
})
# We currently only need a subset of the branches
FORKED_BRANCH_SHA
=
{
'add-submodule-version-bump'
=>
'3f547c08'
,
'master'
=>
'5937ac0'
}
# Test environment
# Test environment
#
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment