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
5ce9f89c
Commit
5ce9f89c
authored
Oct 21, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8102 from cirosantilli/use-memoized-project
Use @project on controllers, don't call method
parents
456de99b
9e1b97ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
38 deletions
+41
-38
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+2
-2
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+22
-19
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+6
-6
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+1
-1
app/controllers/projects/team_members_controller.rb
app/controllers/projects/team_members_controller.rb
+4
-4
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+6
-6
No files found.
app/controllers/admin/projects_controller.rb
View file @
5ce9f89c
...
...
@@ -36,10 +36,10 @@ class Admin::ProjectsController < Admin::ApplicationController
end
def
group
@group
||=
project
.
group
@group
||=
@
project
.
group
end
def
repository
@repository
||=
project
.
repository
@repository
||=
@
project
.
repository
end
end
app/controllers/application_controller.rb
View file @
5ce9f89c
...
...
@@ -81,28 +81,31 @@ class ApplicationController < ActionController::Base
end
def
project
id
=
params
[
:project_id
]
||
params
[
:id
]
# Redirect from
# localhost/group/project.git
# to
# localhost/group/project
#
if
id
=~
/\.git\Z/
redirect_to
request
.
original_url
.
gsub
(
/\.git\Z/
,
''
)
and
return
end
unless
@project
id
=
params
[
:project_id
]
||
params
[
:id
]
# Redirect from
# localhost/group/project.git
# to
# localhost/group/project
#
if
id
=~
/\.git\Z/
redirect_to
request
.
original_url
.
gsub
(
/\.git\Z/
,
''
)
and
return
end
@project
=
Project
.
find_with_namespace
(
id
)
@project
=
Project
.
find_with_namespace
(
id
)
if
@project
and
can?
(
current_user
,
:read_project
,
@project
)
@project
elsif
current_user
.
nil?
@project
=
nil
authenticate_user!
else
@project
=
nil
render_404
and
return
if
@project
and
can?
(
current_user
,
:read_project
,
@project
)
@project
elsif
current_user
.
nil?
@project
=
nil
authenticate_user!
else
@project
=
nil
render_404
and
return
end
end
@project
end
def
repository
...
...
app/controllers/projects/commit_controller.rb
View file @
5ce9f89c
...
...
@@ -11,12 +11,12 @@ class Projects::CommitController < Projects::ApplicationController
def
show
return
git_not_found!
unless
@commit
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@line_notes
=
@
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
@
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@diffs
=
@commit
.
diffs
@note
=
project
.
build_commit_note
(
commit
)
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@notes
=
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@note
=
@
project
.
build_commit_note
(
commit
)
@notes_count
=
@
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@notes
=
@
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@noteable
=
@commit
@comments_allowed
=
@reply_allowed
=
true
@comments_target
=
{
...
...
@@ -32,6 +32,6 @@ class Projects::CommitController < Projects::ApplicationController
end
def
commit
@commit
||=
project
.
repository
.
commit
(
params
[
:id
])
@commit
||=
@
project
.
repository
.
commit
(
params
[
:id
])
end
end
app/controllers/projects/deploy_keys_controller.rb
View file @
5ce9f89c
...
...
@@ -42,7 +42,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def
enable
project
.
deploy_keys
<<
available_keys
.
find
(
params
[
:id
])
@
project
.
deploy_keys
<<
available_keys
.
find
(
params
[
:id
])
redirect_to
project_deploy_keys_path
(
@project
)
end
...
...
app/controllers/projects/team_members_controller.rb
View file @
5ce9f89c
...
...
@@ -10,7 +10,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
def
new
@user_project_relation
=
project
.
project_members
.
new
@user_project_relation
=
@
project
.
project_members
.
new
end
def
create
...
...
@@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
def
update
@user_project_relation
=
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
=
@
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
.
update_attributes
(
member_params
)
unless
@user_project_relation
.
valid?
...
...
@@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
def
destroy
@user_project_relation
=
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
=
@
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
.
destroy
respond_to
do
|
format
|
...
...
@@ -46,7 +46,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
def
leave
project
.
project_members
.
find_by
(
user_id:
current_user
).
destroy
@
project
.
project_members
.
find_by
(
user_id:
current_user
).
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
...
...
app/controllers/projects_controller.rb
View file @
5ce9f89c
...
...
@@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
end
def
import
if
project
.
import_finished?
if
@
project
.
import_finished?
redirect_to
@project
return
end
...
...
@@ -98,7 +98,7 @@ class ProjectsController < ApplicationController
end
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
@
project
)
::
Projects
::
DestroyService
.
new
(
@project
,
current_user
,
{}).
execute
...
...
@@ -148,8 +148,8 @@ class ProjectsController < ApplicationController
end
def
archive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
project
)
project
.
archive!
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@
project
)
@
project
.
archive!
respond_to
do
|
format
|
format
.
html
{
redirect_to
@project
}
...
...
@@ -157,8 +157,8 @@ class ProjectsController < ApplicationController
end
def
unarchive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
project
)
project
.
unarchive!
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@
project
)
@
project
.
unarchive!
respond_to
do
|
format
|
format
.
html
{
redirect_to
@project
}
...
...
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