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
Kazuhiko Shiozaki
gitlab-ce
Commits
f19cdee8
Commit
f19cdee8
authored
Jan 15, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove commit_load_context.rb
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
8bfc62fb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
52 deletions
+23
-52
app/contexts/commit_load_context.rb
app/contexts/commit_load_context.rb
+0
-34
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+20
-15
lib/api/repositories.rb
lib/api/repositories.rb
+3
-3
No files found.
app/contexts/commit_load_context.rb
deleted
100644 → 0
View file @
8bfc62fb
class
CommitLoadContext
<
BaseContext
def
execute
result
=
{
commit:
nil
,
suppress_diff:
false
,
line_notes:
[],
notes_count:
0
,
note:
nil
,
status: :ok
}
commit
=
project
.
repository
.
commit
(
params
[
:id
])
if
commit
line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
result
[
:commit
]
=
commit
result
[
:note
]
=
project
.
build_commit_note
(
commit
)
result
[
:line_notes
]
=
line_notes
result
[
:notes_count
]
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
result
[
:branches
]
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
begin
result
[
:suppress_diff
]
=
true
if
commit
.
diff_suppress?
&&
!
params
[
:force_show_diff
]
result
[
:force_suppress_diff
]
=
commit
.
diff_force_suppress?
rescue
Grit
::
Git
::
GitTimeout
result
[
:suppress_diff
]
=
true
result
[
:status
]
=
:huge_commit
end
end
result
end
end
app/controllers/projects/commit_controller.rb
View file @
f19cdee8
...
@@ -6,30 +6,31 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -6,30 +6,31 @@ class Projects::CommitController < Projects::ApplicationController
before_filter
:authorize_read_project!
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
before_filter
:commit
def
show
def
show
re
sult
=
CommitLoadContext
.
new
(
project
,
current_user
,
params
).
execute
re
turn
git_not_found!
unless
@commit
@commit
=
result
[
:commit
]
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
if
@commit
.
nil?
begin
git_not_found!
@suppress_diff
=
true
if
commit
.
diff_suppress?
&&
!
params
[
:force_show_diff
]
return
@force_suppress_diff
=
commit
.
diff_force_suppress?
rescue
Grit
::
Git
::
GitTimeout
@suppress_diff
=
true
@status
=
:huge_commit
end
end
@suppress_diff
=
result
[
:suppress_diff
]
@note
=
project
.
build_commit_note
(
commit
)
@force_suppress_diff
=
result
[
:force_suppress_diff
]
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@note
=
result
[
:note
]
@line_notes
=
result
[
:line_notes
]
@branches
=
result
[
:branches
]
@notes_count
=
result
[
:notes_count
]
@notes
=
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@notes
=
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@noteable
=
@commit
@noteable
=
@commit
@comments_allowed
=
@reply_allowed
=
true
@comments_allowed
=
@reply_allowed
=
true
@comments_target
=
{
noteable_type:
'Commit'
,
@comments_target
=
{
commit_id:
@commit
.
id
}
noteable_type:
'Commit'
,
commit_id:
@commit
.
id
}
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
...
@@ -42,4 +43,8 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -42,4 +43,8 @@ class Projects::CommitController < Projects::ApplicationController
format
.
patch
{
render
text:
@commit
.
to_patch
}
format
.
patch
{
render
text:
@commit
.
to_patch
}
end
end
end
end
def
commit
@commit
||=
project
.
repository
.
commit
(
params
[
:id
])
end
end
end
lib/api/repositories.rb
View file @
f19cdee8
...
@@ -124,9 +124,9 @@ module API
...
@@ -124,9 +124,9 @@ module API
# GET /projects/:id/repository/commits/:sha/diff
# GET /projects/:id/repository/commits/:sha/diff
get
":id/repository/commits/:sha/diff"
do
get
":id/repository/commits/:sha/diff"
do
sha
=
params
[
:sha
]
sha
=
params
[
:sha
]
result
=
CommitLoadContext
.
new
(
user_project
,
current_user
,
{
id:
sha
}).
execute
commit
=
user_project
.
repository
.
commit
(
sha
)
not_found!
"Commit"
unless
result
[
:commit
]
not_found!
"Commit"
unless
commit
result
[
:commit
]
.
diffs
commit
.
diffs
end
end
# Get a project repository tree
# Get a project repository tree
...
...
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