2012-09-17 10:08:02 -04:00
|
|
|
# Controller for a specific Commit
|
|
|
|
#
|
|
|
|
# Not to be confused with CommitsController, plural.
|
2013-06-23 12:47:22 -04:00
|
|
|
class Projects::CommitController < Projects::ApplicationController
|
2012-09-17 10:08:02 -04:00
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :authorize_code_access!
|
|
|
|
before_filter :require_non_empty_project
|
2014-01-15 08:06:12 -05:00
|
|
|
before_filter :commit
|
2012-09-17 10:08:02 -04:00
|
|
|
|
|
|
|
def show
|
2014-01-15 08:06:12 -05:00
|
|
|
return git_not_found! unless @commit
|
2012-09-17 10:08:02 -04:00
|
|
|
|
2014-01-15 08:06:12 -05:00
|
|
|
@line_notes = project.notes.for_commit_id(commit.id).inline
|
|
|
|
@branches = project.repository.branch_names_contains(commit.id)
|
2013-06-12 09:43:58 -04:00
|
|
|
|
2014-01-15 08:06:12 -05:00
|
|
|
begin
|
|
|
|
@suppress_diff = true if commit.diff_suppress? && !params[:force_show_diff]
|
|
|
|
@force_suppress_diff = commit.diff_force_suppress?
|
|
|
|
rescue Grit::Git::GitTimeout
|
|
|
|
@suppress_diff = true
|
|
|
|
@status = :huge_commit
|
2013-06-03 11:04:41 -04:00
|
|
|
end
|
2012-09-17 10:08:02 -04:00
|
|
|
|
2014-01-15 08:06:12 -05:00
|
|
|
@note = project.build_commit_note(commit)
|
|
|
|
@notes_count = project.notes.for_commit_id(commit.id).count
|
2013-12-25 06:32:43 -05:00
|
|
|
@notes = project.notes.for_commit_id(@commit.id).not_inline.fresh
|
2013-12-25 15:32:48 -05:00
|
|
|
@noteable = @commit
|
2012-10-29 10:55:37 -04:00
|
|
|
@comments_allowed = @reply_allowed = true
|
2014-01-15 08:06:12 -05:00
|
|
|
@comments_target = {
|
|
|
|
noteable_type: 'Commit',
|
|
|
|
commit_id: @commit.id
|
|
|
|
}
|
2012-09-25 18:46:19 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2014-01-15 08:31:49 -05:00
|
|
|
if @status == :huge_commit
|
2012-09-25 18:46:19 -04:00
|
|
|
render "huge_commit" and return
|
|
|
|
end
|
|
|
|
end
|
2012-09-17 10:08:02 -04:00
|
|
|
|
2012-11-22 14:49:44 -05:00
|
|
|
format.diff { render text: @commit.to_diff }
|
2012-11-22 06:45:39 -05:00
|
|
|
format.patch { render text: @commit.to_patch }
|
2012-09-17 10:08:02 -04:00
|
|
|
end
|
|
|
|
end
|
2014-01-15 08:06:12 -05:00
|
|
|
|
|
|
|
def commit
|
|
|
|
@commit ||= project.repository.commit(params[:id])
|
|
|
|
end
|
2012-09-17 10:08:02 -04:00
|
|
|
end
|