Commit d521cf8d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor/gitlab_git_2' of /home/git/repositories/gitlab/gitlabhq

parents 5b28bf1e 1e3f09b2
......@@ -23,7 +23,7 @@ gem 'omniauth-github'
# Extracting information from a git repository
# Provide access to Gitlab::Git library
gem 'gitlab_git', '~> 1.4.1'
gem "gitlab_git", "~> 2.0.0.pre"
# Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 1.0.1', require: 'grack'
......
......@@ -176,7 +176,7 @@ GEM
gitlab-pygments.rb (0.3.2)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
gitlab_git (1.4.1)
gitlab_git (2.0.0.pre)
activesupport (~> 3.2.13)
github-linguist (~> 2.3.4)
gitlab-grit (~> 2.6.0)
......@@ -275,7 +275,7 @@ GEM
minitest (4.7.4)
modernizr (2.6.2)
sprockets (~> 2.0)
multi_json (1.7.7)
multi_json (1.7.8)
multi_xml (0.5.4)
multipart-post (1.2.0)
mysql2 (0.3.11)
......@@ -568,7 +568,7 @@ DEPENDENCIES
gitlab-gollum-lib (~> 1.0.1)
gitlab-grack (~> 1.0.1)
gitlab-pygments.rb (~> 0.3.2)
gitlab_git (~> 1.4.1)
gitlab_git (~> 2.0.0.pre)
gitlab_meta (= 6.0)
gitlab_omniauth-ldap (= 1.0.3)
gon
......
......@@ -11,6 +11,10 @@ class Projects::BranchesController < Projects::ApplicationController
@branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30)
end
def recent
@branches = @repository.recent_branches
end
def create
@repository.add_branch(params[:branch_name], params[:ref])
......
......@@ -10,7 +10,7 @@ class Projects::EditTreeController < Projects::ApplicationController
before_filter :edit_requirements, only: [:show, :update]
def show
@last_commit = @project.repository.last_commit_for(@ref, @path).sha
@last_commit = Gitlab::Git::Commit.last_for_path(@project.repository, @ref, @path).sha
end
def update
......
......@@ -4,10 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController
before_filter :authorize_code_access!
before_filter :require_non_empty_project
def show
@activities = @repository.commits_with_refs(20)
end
def stats
@stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref)
@graph = @stats.graph
......
......@@ -137,7 +137,7 @@ class MergeRequest < ActiveRecord::Base
end
def unmerged_diffs
project.repository.diffs_between(source_branch, target_branch)
Gitlab::Git::Diff.between(project.repository, source_branch, target_branch)
end
def last_commit
......
......@@ -18,19 +18,25 @@ class Repository
end
def commit(id = nil)
commit = raw_repository.commit(id)
commit = Gitlab::Git::Commit.find(raw_repository, id)
commit = Commit.new(commit) if commit
commit
end
def commits(ref, path = nil, limit = nil, offset = nil)
commits = raw_repository.commits(ref, path, limit, offset)
commits = Gitlab::Git::Commit.where(
repo: raw_repository,
ref: ref,
path: path,
limit: limit,
offset: offset,
)
commits = Commit.decorate(commits) if commits.present?
commits
end
def commits_between(target, source)
commits = raw_repository.commits_between(target, source)
def commits_between(from, to)
commits = Gitlab::Git::Commit.between(raw_repository, from, to)
commits = Commit.decorate(commits) if commits.present?
commits
end
......@@ -43,6 +49,12 @@ class Repository
tags.find { |tag| tag.name == name }
end
def recent_branches(limit = 20)
branches.sort do |a, b|
a.commit.committed_date <=> b.commit.committed_date
end[0..limit]
end
def add_branch(branch_name, ref)
Rails.cache.delete(cache_key(:branch_names))
......
%ul.nav.nav-pills.nav-stacked
= nav_link(path: 'repositories#show') do
= link_to 'Recent', project_repository_path(@project)
= nav_link(path: 'branches#recent') do
= link_to 'Recent', recent_project_branches_path(@project)
= nav_link(path: 'protected_branches#index') do
= link_to project_protected_branches_path(@project) do
Protected
......
= render "projects/commits/head"
.row
.span3
= render "projects/repositories/filter"
= render "filter"
.span9
- unless @branches.empty?
%ul.bordered-list
......
......@@ -4,6 +4,5 @@
= render "filter"
.span9
%ul.bordered-list
- @activities.each do |update|
= render "projects/branches/branch", branch: update.head
- @branches.each do |branch|
= render "projects/branches/branch", branch: branch
......@@ -7,7 +7,7 @@
= link_to 'Compare', project_compare_index_path(@project)
= nav_link(html_options: {class: branches_tab_class}) do
= link_to project_repository_path(@project) do
= link_to recent_project_branches_path(@project) do
Branches
%span.badge= @repository.branches.length
......
= render "projects/commits/head"
.row
.span3
= render "projects/repositories/filter"
= render "projects/branches/filter"
.span9
.alert.alert-info
%p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}.
......
......@@ -225,8 +225,13 @@ Gitlab::Application.routes.draw do
end
end
resources :branches, only: [:index, :new, :create, :destroy] do
collection do
get :recent
end
end
resources :tags, only: [:index, :new, :create, :destroy]
resources :branches, only: [:index, :new, :create, :destroy]
resources :protected_branches, only: [:index, :create, :destroy]
resources :refs, only: [] do
......
......@@ -95,13 +95,9 @@ module ExtractsPath
# resolved (e.g., when a user inserts an invalid path or ref).
def assign_ref_vars
@id = get_id
@ref, @path = extract_ref(@id)
@repo = @project.repository
@commit = @repo.commit(@ref)
@tree = Tree.new(@repo, @commit.id, @ref, @path)
@hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_project_ref_path(@project, @ref, @path)
......
......@@ -49,7 +49,7 @@ module Gitlab
protected
def can_edit?(last_commit)
current_last_commit = @project.repository.last_commit_for(ref, file_path).sha
current_last_commit = Gitlab::Git::Commit.last_for_path(@project.repository, ref, file_path).sha
last_commit == current_last_commit
end
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::CommitController do
let(:project) { create(:project_with_code) }
let(:user) { create(:user) }
let(:commit) { project.repository.last_commit_for("master") }
let(:commit) { project.repository.commit("master") }
before do
sign_in(user)
......
......@@ -175,8 +175,8 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository" do
subject { project_repository_path(project) }
describe "GET /project_code/branches/recent" do
subject { recent_project_branches_path(project) }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
......@@ -186,7 +186,7 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository/branches" do
describe "GET /project_code/branches" do
subject { project_branches_path(project) }
before do
......@@ -202,7 +202,7 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository/tags" do
describe "GET /project_code/tags" do
subject { project_tags_path(project) }
before do
......@@ -417,8 +417,8 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository" do
subject { project_repository_path(project) }
describe "GET /project_code/branches/recent" do
subject { recent_project_branches_path(project) }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
......@@ -428,7 +428,7 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository/branches" do
describe "GET /project_code/branches" do
subject { project_branches_path(project) }
before do
......@@ -444,7 +444,7 @@ describe "Application access" do
it { should be_denied_for :visitor }
end
describe "GET /project_code/repository/tags" do
describe "GET /project_code/tags" do
subject { project_tags_path(project) }
before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment