commits_controller.rb 1007 Bytes
Newer Older
gitlabhq's avatar
gitlabhq committed
1
2
3
4
require "base64"

class CommitsController < ApplicationController
  before_filter :project
gitlabhq's avatar
updated    
gitlabhq committed
5
  layout "project"
gitlabhq's avatar
gitlabhq committed
6
7
8
9

  # Authorize
  before_filter :add_project_abilities
  before_filter :authorize_read_project!
gitlabhq's avatar
gitlabhq committed
10
  before_filter :require_non_empty_project
11
  before_filter :load_refs, :only => :index # load @branch, @tag & @ref
gitlabhq's avatar
gitlabhq committed
12

13

14
  def index
gitlabhq's avatar
gitlabhq committed
15
    @repo = project.repo
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
16
    limit, offset = (params[:limit] || 20), (params[:offset] || 0) 
gitlabhq's avatar
gitlabhq committed
17

18
19
20
21
22
    @commits = if params[:path]
                 @repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
               else
                 @repo.commits(@ref, limit, offset)
               end
gitlabhq's avatar
gitlabhq committed
23
24
25
26
27
28
29
30
31

    respond_to do |format|
      format.html # index.html.erb
      format.js
    end
  end

  def show
    @commit = project.repo.commits(params[:id]).first
32
33
    @notes = project.commit_notes(@commit).fresh.limit(20)
    @note = @project.build_commit_note(@commit)
gitlabhq's avatar
gitlabhq committed
34

gitlabhq's avatar
gitlabhq committed
35
36
    respond_to do |format| 
      format.html
37
      format.js { respond_with_notes }
gitlabhq's avatar
gitlabhq committed
38
39
40
    end
  end
end