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
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
|
|
|
before_action :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
|
|
|
|
2015-04-21 09:15:49 -04:00
|
|
|
@line_notes = commit.notes.inline
|
2014-09-25 08:26:35 -04:00
|
|
|
@diffs = @commit.diffs
|
2014-10-19 17:20:55 -04:00
|
|
|
@note = @project.build_commit_note(commit)
|
2015-04-21 09:15:49 -04:00
|
|
|
@notes_count = commit.notes.count
|
|
|
|
@notes = commit.notes.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|
|
2014-07-15 11:28:21 -04:00
|
|
|
format.html
|
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
|
|
|
|
2015-02-03 00:30:11 -05:00
|
|
|
def branches
|
|
|
|
@branches = @project.repository.branch_names_contains(commit.id)
|
|
|
|
@tags = @project.repository.tag_names_contains(commit.id)
|
|
|
|
render layout: false
|
|
|
|
end
|
|
|
|
|
2014-01-15 08:06:12 -05:00
|
|
|
def commit
|
2015-04-21 09:13:40 -04:00
|
|
|
@commit ||= @project.commit(params[:id])
|
2014-01-15 08:06:12 -05:00
|
|
|
end
|
2012-09-17 10:08:02 -04:00
|
|
|
end
|