repositories_controller.rb 751 Bytes
Newer Older
1
class Projects::RepositoriesController < Projects::ApplicationController
2 3
  # Authorize
  before_filter :authorize_read_project!
4
  before_filter :authorize_code_access!
5 6 7
  before_filter :require_non_empty_project

  def show
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8
    @activities = @repository.commits_with_refs(20)
9
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
10

randx's avatar
randx committed
11
  def stats
12
    @stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref)
randx's avatar
randx committed
13 14 15
    @graph = @stats.graph
  end

16 17
  def archive
    unless can?(current_user, :download_code, @project)
randx's avatar
randx committed
18
      render_404 and return
19 20
    end

21 22 23
    storage_path = Rails.root.join("tmp", "repositories")

    file_path = @repository.archive_repo(params[:ref], storage_path)
24 25 26 27 28 29 30

    if file_path
      # Send file to user
      send_file file_path
    else
      render_404
    end
31
  end
32
end