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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
7d279f93
Commit
7d279f93
authored
Feb 22, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better error handling for not found resource, gitolite error
parent
9e6d0710
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
7 deletions
+73
-7
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+18
-5
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+3
-0
app/controllers/errors_controller.rb
app/controllers/errors_controller.rb
+3
-1
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+1
-1
app/views/errors/access_denied.html.haml
app/views/errors/access_denied.html.haml
+5
-0
app/views/errors/git_not_found.html.haml
app/views/errors/git_not_found.html.haml
+9
-0
app/views/errors/gitolite.html.haml
app/views/errors/gitolite.html.haml
+18
-0
app/views/errors/not_found.html.haml
app/views/errors/not_found.html.haml
+5
-0
app/views/layouts/error.html.haml
app/views/layouts/error.html.haml
+11
-0
No files found.
app/controllers/application_controller.rb
View file @
7d279f93
...
...
@@ -5,7 +5,11 @@ class ApplicationController < ActionController::Base
helper_method
:abilities
,
:can?
rescue_from
Gitlabhq
::
Gitolite
::
AccessDenied
do
|
exception
|
render
:file
=>
File
.
join
(
Rails
.
root
,
"public"
,
"githost_error"
),
:layout
=>
false
render
"errors/gitolite"
,
:layout
=>
"error"
end
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
render
"errors/not_found"
,
:layout
=>
"error"
end
layout
:layout_by_resource
...
...
@@ -33,7 +37,8 @@ class ApplicationController < ActionController::Base
end
def
project
@project
||=
Project
.
find_by_code
(
params
[
:project_id
])
@project
||=
current_user
.
projects
.
find_by_code
(
params
[
:project_id
])
@project
||
render_404
end
def
add_project_abilities
...
...
@@ -45,15 +50,23 @@ class ApplicationController < ActionController::Base
end
def
authorize_project!
(
action
)
return
render_404
unless
can?
(
current_user
,
action
,
project
)
return
access_denied!
unless
can?
(
current_user
,
action
,
project
)
end
def
authorize_code_access!
return
render_404
unless
can?
(
current_user
,
:download_code
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:download_code
,
project
)
end
def
access_denied!
render_404
render
"errors/access_denied"
,
:layout
=>
"error"
end
def
not_found!
render
"errors/not_found"
,
:layout
=>
"error"
end
def
git_not_found!
render
"errors/git_not_found"
,
:layout
=>
"error"
end
def
method_missing
(
method_sym
,
*
arguments
,
&
block
)
...
...
app/controllers/commits_controller.rb
View file @
7d279f93
...
...
@@ -26,6 +26,9 @@ class CommitsController < ApplicationController
def
show
@commit
=
project
.
commit
(
params
[
:id
])
git_not_found!
and
return
unless
@commit
@notes
=
project
.
commit_notes
(
@commit
).
fresh
.
limit
(
20
)
@note
=
@project
.
build_commit_note
(
@commit
)
...
...
app/controllers/errors_controller.rb
View file @
7d279f93
class
ErrorsController
<
ApplicationController
layout
"error"
def
githost
render
:file
=>
File
.
join
(
Rails
.
root
,
"public"
,
"githost_error"
),
:layout
=>
false
render
"errors/gitolite"
end
end
app/controllers/merge_requests_controller.rb
View file @
7d279f93
...
...
@@ -36,7 +36,7 @@ class MergeRequestsController < ApplicationController
def
show
unless
@project
.
repo
.
heads
.
map
(
&
:name
).
include?
(
@merge_request
.
target_branch
)
&&
@project
.
repo
.
heads
.
map
(
&
:name
).
include?
(
@merge_request
.
source_branch
)
head
(
404
)
and
return
git_not_found!
and
return
end
@notes
=
@merge_request
.
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
...
...
app/views/errors/access_denied.html.haml
0 → 100644
View file @
7d279f93
.alert-message.block-message.error
%h3
Access Denied
%hr
%p
Youre not allowed to access this page
%p
Ream more about project permissions
#{
link_to
"here"
,
help_permissions_path
,
:class
=>
"vlink"
}
app/views/errors/git_not_found.html.haml
0 → 100644
View file @
7d279f93
.alert-message.block-message.error
%h3
Git Resource Not found
%hr
%p
Application cant get access to some
%span
.label
branch
or
%span
.label
commit
in your repository. Maybe it was moved
app/views/errors/gitolite.html.haml
0 → 100644
View file @
7d279f93
.alert-message.block-message.error
%h3
Gitolite Error
%hr
%h4
Application cant get access to your gitolite system.
%ol
%li
%p
Check 'config/gitlab.yml' for correct settings.
%li
%p
Make sure web server user has access to gitolite.
%a
{
:href
=>
"https://github.com/gitlabhq/gitlabhq/wiki/Gitolite"
}
Setup tutorial
%li
%p
Try:
%pre
sudo chmod -R 770 /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
app/views/errors/not_found.html.haml
0 → 100644
View file @
7d279f93
.alert-message.block-message.error
%h3
Not found
%hr
%p
Resource you were looking for doesn't exist.
%P
You may have mistyped the address or it was removed.
app/views/layouts/error.html.haml
0 → 100644
View file @
7d279f93
!!! 5
%html
{
:lang
=>
"en"
}
=
render
"layouts/head"
%body
.application
=
render
"layouts/flash"
=
render
"layouts/head_panel"
,
:title
=>
""
.container
%nav
.main_menu
=
render
"layouts/const_menu_links"
.content
%h3
=
yield
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