Commit ab729e5c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce

parents b0a4ec5e 3a72af48
...@@ -31,7 +31,8 @@ gem 'omniauth-shibboleth' ...@@ -31,7 +31,8 @@ gem 'omniauth-shibboleth'
# Extracting information from a git repository # Extracting information from a git repository
# Provide access to Gitlab::Git library # Provide access to Gitlab::Git library
gem "gitlab_git", '~> 6.0' # gem "gitlab_git", path: '../../gitlab_git'
gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git', ref: 'b53b948a9248ea3a4b7f2bd6c7f9938fbd5e952b'
# Ruby/Rack Git Smart-HTTP Server Handler # Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
...@@ -157,7 +158,7 @@ gem "rack-attack" ...@@ -157,7 +158,7 @@ gem "rack-attack"
# Ace editor # Ace editor
gem 'ace-rails-ap' gem 'ace-rails-ap'
# Keyboard shortcuts # Keyboard shortcuts
gem 'mousetrap-rails' gem 'mousetrap-rails'
# Semantic UI Sass for Sidebar # Semantic UI Sass for Sidebar
......
GIT
remote: https://gitlab.com/gitlab-org/gitlab_git.git
revision: b53b948a9248ea3a4b7f2bd6c7f9938fbd5e952b
ref: b53b948a9248ea3a4b7f2bd6c7f9938fbd5e952b
specs:
gitlab_git (7.0.0.pre)
activesupport (~> 4.0)
charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0)
rubyzip (~> 1.1)
rugged (~> 0.21.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -179,12 +191,6 @@ GEM ...@@ -179,12 +191,6 @@ GEM
mime-types (~> 1.19) mime-types (~> 1.19)
gitlab_emoji (0.0.1.1) gitlab_emoji (0.0.1.1)
emoji (~> 1.0.1) emoji (~> 1.0.1)
gitlab_git (6.3.0)
activesupport (~> 4.0)
charlock_holmes (~> 0.6)
gitlab-grit (~> 2.6)
gitlab-linguist (~> 3.0)
rugged (~> 0.21.0)
gitlab_meta (7.0) gitlab_meta (7.0)
gitlab_omniauth-ldap (1.1.0) gitlab_omniauth-ldap (1.1.0)
net-ldap (~> 0.7.0) net-ldap (~> 0.7.0)
...@@ -440,6 +446,7 @@ GEM ...@@ -440,6 +446,7 @@ GEM
ruby-progressbar (1.2.0) ruby-progressbar (1.2.0)
rubyntlm (0.1.1) rubyntlm (0.1.1)
rubypants (0.2.0) rubypants (0.2.0)
rubyzip (1.1.6)
rugged (0.21.0) rugged (0.21.0)
safe_yaml (0.9.7) safe_yaml (0.9.7)
sanitize (2.1.0) sanitize (2.1.0)
...@@ -617,7 +624,7 @@ DEPENDENCIES ...@@ -617,7 +624,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.0.pre) gitlab-grack (~> 2.0.0.pre)
gitlab-linguist (~> 3.0.0) gitlab-linguist (~> 3.0.0)
gitlab_emoji (~> 0.0.1.1) gitlab_emoji (~> 0.0.1.1)
gitlab_git (~> 6.0) gitlab_git!
gitlab_meta (= 7.0) gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.1.0) gitlab_omniauth-ldap (= 1.1.0)
gollum-lib (~> 3.0.0) gollum-lib (~> 3.0.0)
......
...@@ -19,13 +19,7 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -19,13 +19,7 @@ class Projects::CommitController < Projects::ApplicationController
[] []
end end
begin @diffs = @commit.diffs
@diffs = @commit.diffs
rescue Grit::Git::GitTimeout
@diffs = []
@diff_timeout = true
end
@note = project.build_commit_note(commit) @note = project.build_commit_note(commit)
@notes_count = project.notes.for_commit_id(commit.id).count @notes_count = project.notes.for_commit_id(commit.id).count
@notes = project.notes.for_commit_id(@commit.id).not_inline.fresh @notes = project.notes.for_commit_id(@commit.id).not_inline.fresh
......
...@@ -5,7 +5,7 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -5,7 +5,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
before_filter :require_non_empty_project before_filter :require_non_empty_project
def stats def stats
@stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref) @stats = Gitlab::Git::Stats.new(@repository.raw_repository, @repository.root_ref)
@graph = @stats.graph @graph = @stats.graph
end end
......
...@@ -108,4 +108,8 @@ class Commit ...@@ -108,4 +108,8 @@ class Commit
super super
end end
def parents
@parents ||= Commit.decorate(super)
end
end end
...@@ -107,6 +107,18 @@ class ProjectWiki ...@@ -107,6 +107,18 @@ class ProjectWiki
[title.gsub(/\.[^.]*$/, ""), title_array.join("/")] [title.gsub(/\.[^.]*$/, ""), title_array.join("/")]
end end
def search_files(query)
repository.search_files(query, default_branch)
end
def repository
Repository.new(path_with_namespace, default_branch)
end
def default_branch
wiki.class.default_ref
end
private private
def create_repo! def create_repo!
......
...@@ -25,7 +25,7 @@ class Repository ...@@ -25,7 +25,7 @@ class Repository
raw_repository.empty? raw_repository.empty?
end end
def commit(id = nil) def commit(id = 'HEAD')
return nil unless raw_repository return nil unless raw_repository
commit = Gitlab::Git::Commit.find(raw_repository, id) commit = Gitlab::Git::Commit.find(raw_repository, id)
commit = Commit.new(commit) if commit commit = Commit.new(commit) if commit
...@@ -137,7 +137,7 @@ class Repository ...@@ -137,7 +137,7 @@ class Repository
def graph_log def graph_log
Rails.cache.fetch(cache_key(:graph_log)) do Rails.cache.fetch(cache_key(:graph_log)) do
stats = Gitlab::Git::GitStats.new(raw, root_ref, Gitlab.config.git.timeout) stats = Gitlab::Git::GitStats.new(raw_repository, root_ref, Gitlab.config.git.timeout)
stats.parsed_log stats.parsed_log
end end
end end
......
...@@ -87,14 +87,14 @@ class WikiPage ...@@ -87,14 +87,14 @@ class WikiPage
def version def version
return nil unless persisted? return nil unless persisted?
@version ||= Commit.new(Gitlab::Git::Commit.new(@page.version)) @version ||= @page.version
end end
# Returns an array of Gitlab Commit instances. # Returns an array of Gitlab Commit instances.
def versions def versions
return [] unless persisted? return [] unless persisted?
@page.versions.map { |v| Commit.new(Gitlab::Git::Commit.new(v)) } @page.versions
end end
def commit def commit
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
%tr %tr
%td %td
= link_to project_wiki_path(@project, @page, version_id: commit.id) do = link_to project_wiki_path(@project, @page, version_id: commit.id) do
= commit.short_id = commit.id[0..10]
%td %td
= commit_author_link(commit, avatar: true, size: 24) = commit.author.name
%td %td
= commit.title = commit.message
%td %td
#{time_ago_with_tooltip(version.date)} #{time_ago_with_tooltip(version.date)}
%td %td
......
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
= link_to wiki_page.title, project_wiki_path(@project, wiki_page) = link_to wiki_page.title, project_wiki_path(@project, wiki_page)
%small (#{wiki_page.format}) %small (#{wiki_page.format})
.pull-right .pull-right
%small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} %small Last edited #{time_ago_with_tooltip(wiki_page.commit.authored_date)}
= paginate @wiki_pages, theme: 'gitlab' = paginate @wiki_pages, theme: 'gitlab'
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
%hr %hr
.wiki-last-edit-by .wiki-last-edit-by
Last edited by #{commit_author_link(@page.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@page.commit.created_at)} Last edited by #{@page.commit.author.name} #{time_ago_with_tooltip(@page.commit.authored_date)}
%div.highlighted-data{class: user_color_scheme_class} %div.highlighted-data{class: user_color_scheme_class}
.line-numbers .line-numbers
- blob.data.lines.to_a.size.times do |index| - if blob.data.present?
- offset = defined?(first_line_number) ? first_line_number : 1 - blob.data.lines.to_a.size.times do |index|
- i = index + offset - offset = defined?(first_line_number) ? first_line_number : 1
= link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do - i = index + offset
%i.icon-link = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do
= i %i.icon-link
= i
.highlight .highlight
%pre %pre
%code{ class: highlightjs_class(blob.name) } %code{ class: highlightjs_class(blob.name) }
......
...@@ -14,7 +14,7 @@ module API ...@@ -14,7 +14,7 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/branches # GET /projects/:id/repository/branches
get ":id/repository/branches" do get ":id/repository/branches" do
present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project present user_project.repository.branches.sort_by(&:name), with: Entities::RepoObject, project: user_project
end end
# Get a single branch # Get a single branch
...@@ -25,7 +25,7 @@ module API ...@@ -25,7 +25,7 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/branches/:branch # GET /projects/:id/repository/branches/:branch
get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] } @branch = user_project.repository.branches.find { |item| item.name == params[:branch] }
not_found!("Branch does not exist") if @branch.nil? not_found!("Branch does not exist") if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
end end
......
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
end end
def raw_diff def raw_diff
diff.diff diff.diff.to_s
end end
def next_line(index) def next_line(index)
......
...@@ -4,7 +4,11 @@ module Gitlab ...@@ -4,7 +4,11 @@ module Gitlab
def initialize(project_id, query, repository_ref = nil) def initialize(project_id, query, repository_ref = nil)
@project = Project.find(project_id) @project = Project.find(project_id)
@repository_ref = repository_ref @repository_ref = if repository_ref.present?
repository_ref
else
nil
end
@query = Shellwords.shellescape(query) if query.present? @query = Shellwords.shellescape(query) if query.present?
end end
...@@ -41,7 +45,7 @@ module Gitlab ...@@ -41,7 +45,7 @@ module Gitlab
private private
def blobs def blobs
if project.empty_repo? if project.empty_repo? || query.blank?
[] []
else else
project.repository.search_files(query, repository_ref) project.repository.search_files(query, repository_ref)
...@@ -49,11 +53,11 @@ module Gitlab ...@@ -49,11 +53,11 @@ module Gitlab
end end
def wiki_blobs def wiki_blobs
if project.wiki_enabled? if project.wiki_enabled? && query.present?
wiki_repo = Repository.new(ProjectWiki.new(project).path_with_namespace) project_wiki = ProjectWiki.new(project)
if wiki_repo.exists? unless project_wiki.empty?
wiki_repo.search_files(query) project_wiki.search_files(query)
else else
[] []
end end
......
...@@ -65,15 +65,16 @@ module Gitlab ...@@ -65,15 +65,16 @@ module Gitlab
prepare_satellite!(merge_repo) prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo) update_satellite_source_and_target!(merge_repo)
if merge_request.for_fork? if merge_request.for_fork?
# Only show what is new in the source branch compared to the target branch, not the other way around. repository = Gitlab::Git::Repository.new(merge_repo.path)
# The line below with merge_base is equivalent to diff with three dots (git diff branch1...branch2) diffs = Gitlab::Git::Diff.between(
# From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B" repository,
common_commit = merge_repo.git.native(:merge_base, default_options, ["origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}"]).strip "source/#{merge_request.source_branch}",
diffs = merge_repo.diff(common_commit, "source/#{merge_request.source_branch}") "origin/#{merge_request.target_branch}"
)
else else
raise "Attempt to determine diffs between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]" raise "Attempt to determine diffs between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]"
end end
diffs = diffs.map { |diff| Gitlab::Git::Diff.new(diff) }
return diffs return diffs
end end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
...@@ -97,11 +98,16 @@ module Gitlab ...@@ -97,11 +98,16 @@ module Gitlab
prepare_satellite!(merge_repo) prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo) update_satellite_source_and_target!(merge_repo)
if (merge_request.for_fork?) if (merge_request.for_fork?)
commits = merge_repo.commits_between("origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") repository = Gitlab::Git::Repository.new(merge_repo.path)
commits = Gitlab::Git::Commit.between(
repository,
"origin/#{merge_request.target_branch}",
"source/#{merge_request.source_branch}"
)
else else
raise "Attempt to determine commits between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]" raise "Attempt to determine commits between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]"
end end
commits = commits.map { |commit| Gitlab::Git::Commit.new(commit, nil) }
return commits return commits
end end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
......
...@@ -90,7 +90,7 @@ describe "Internal Project Access", feature: true do ...@@ -90,7 +90,7 @@ describe "Internal Project Access", feature: true do
describe "GET /:project_path/blob" do describe "GET /:project_path/blob" do
before do before do
commit = project.repository.commit commit = project.repository.commit
path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob) }.first.name path = '.gitignore'
@blob_path = project_blob_path(project, File.join(commit.id, path)) @blob_path = project_blob_path(project, File.join(commit.id, path))
end end
......
...@@ -90,7 +90,7 @@ describe "Private Project Access", feature: true do ...@@ -90,7 +90,7 @@ describe "Private Project Access", feature: true do
describe "GET /:project_path/blob" do describe "GET /:project_path/blob" do
before do before do
commit = project.repository.commit commit = project.repository.commit
path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob) }.first.name path = '.gitignore'
@blob_path = project_blob_path(project, File.join(commit.id, path)) @blob_path = project_blob_path(project, File.join(commit.id, path))
end end
......
...@@ -95,7 +95,7 @@ describe "Public Project Access", feature: true do ...@@ -95,7 +95,7 @@ describe "Public Project Access", feature: true do
describe "GET /:project_path/blob" do describe "GET /:project_path/blob" do
before do before do
commit = project.repository.commit commit = project.repository.commit
path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob) }.first.name path = '.gitignore'
@blob_path = project_blob_path(project, File.join(commit.id, path)) @blob_path = project_blob_path(project, File.join(commit.id, path))
end end
......
...@@ -36,7 +36,7 @@ describe WikiPage do ...@@ -36,7 +36,7 @@ describe WikiPage do
end end
it "sets the version attribute" do it "sets the version attribute" do
@wiki_page.version.should be_a Commit @wiki_page.version.should be_a Grit::Commit
end end
end end
end end
......
...@@ -17,7 +17,7 @@ describe API::API, api: true do ...@@ -17,7 +17,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/branches", user) get api("/projects/#{project.id}/repository/branches", user)
response.status.should == 200 response.status.should == 200
json_response.should be_an Array json_response.should be_an Array
json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name json_response.first['name'].should == project.repository.branch_names.first
end end
end end
......
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