Welcome to mirror list, hosted at ThFree Co, Russian Federation.

commits_controller.rb « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a91c28480ccfa3724c0746979f37e4f64940f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require "base64"

class CommitsController < ApplicationController
  before_filter :project
  layout "project"

  # Authorize
  before_filter :add_project_abilities
  before_filter :authorize_read_project!
  before_filter :authorize_code_access!
  before_filter :require_non_empty_project
  before_filter :load_refs, :only => :index # load @branch, @tag & @ref
  before_filter :render_full_content

  def index
    @repo = project.repo
    @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)

    @commits = @project.commits(@ref, params[:path], @limit, @offset)

    respond_to do |format|
      format.html # index.html.erb
      format.js
      format.atom { render :layout => false }
    end
  end

  def show
    @commit = project.commit(params[:id])

    git_not_found! and return unless @commit

    @commit = CommitDecorator.decorate(@commit)

    @note = @project.build_commit_note(@commit)
    @comments_allowed = true
    @line_notes = project.commit_line_notes(@commit)

    @notes_count = @line_notes.count + project.commit_notes(@commit).count

    if @commit.diffs.size > 200 && !params[:force_show_diff]
      @suppress_diff = true 
    end
  end

  def compare
    first = project.commit(params[:to].try(:strip))
    last = project.commit(params[:from].try(:strip))

    @diffs = []
    @commits = []
    @line_notes = []

    if first && last
      commits = [first, last].sort_by(&:created_at)
      younger = commits.first
      older = commits.last


      @commits = project.repo.commits_between(younger.id, older.id).map {|c| Commit.new(c)}
      @diffs = project.repo.diff(younger.id, older.id) rescue []
      @commit = Commit.new(older)
    end
  end
end