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
|
2014-10-13 15:31:49 -04:00
|
|
|
before_filter :authorize_download_code!
|
2012-09-17 10:08:02 -04:00
|
|
|
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-10-19 17:20:55 -04:00
|
|
|
@line_notes = @project.notes.for_commit_id(commit.id).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)
|
|
|
|
@notes_count = @project.notes.for_commit_id(commit.id).count
|
|
|
|
@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|
|
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
|
2014-10-19 17:20:55 -04:00
|
|
|
@commit ||= @project.repository.commit(params[:id])
|
2014-01-15 08:06:12 -05:00
|
|
|
end
|
2012-09-17 10:08:02 -04:00
|
|
|
end
|