Merge branch 'gitaly-renames-annotations' into 'master'
Gitaly deletions and annotations See merge request !13280
This commit is contained in:
commit
9b21668663
|
@ -941,7 +941,7 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def repo
|
||||
repository.raw
|
||||
repository.rugged
|
||||
end
|
||||
|
||||
def url_to_repo
|
||||
|
|
|
@ -102,7 +102,7 @@ module Gitlab
|
|||
if is_enabled
|
||||
repo.gitaly_commit_client.between(base, head)
|
||||
else
|
||||
repo.commits_between(base, head).map { |c| decorate(c) }
|
||||
repo.rugged_commits_between(base, head).map { |c| decorate(c) }
|
||||
end
|
||||
end
|
||||
rescue Rugged::ReferenceError
|
||||
|
|
|
@ -58,11 +58,6 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
# Alias to old method for compatibility
|
||||
def raw
|
||||
rugged
|
||||
end
|
||||
|
||||
def rugged
|
||||
@rugged ||= Rugged::Repository.new(path, alternates: alternate_object_directories)
|
||||
rescue Rugged::RepositoryError, Rugged::OSError
|
||||
|
@ -296,6 +291,7 @@ module Gitlab
|
|||
# after: Time.new(2016, 4, 21, 14, 32, 10)
|
||||
# )
|
||||
#
|
||||
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/446
|
||||
def log(options)
|
||||
raw_log(options).map { |c| Commit.decorate(c) }
|
||||
end
|
||||
|
@ -324,7 +320,9 @@ module Gitlab
|
|||
# Return a collection of Rugged::Commits between the two revspec arguments.
|
||||
# See http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
|
||||
# a detailed list of valid arguments.
|
||||
def commits_between(from, to)
|
||||
#
|
||||
# Gitaly note: JV: to be deprecated in favor of Commit.between
|
||||
def rugged_commits_between(from, to)
|
||||
walker = Rugged::Walker.new(rugged)
|
||||
walker.sorting(Rugged::SORT_NONE | Rugged::SORT_REVERSE)
|
||||
|
||||
|
@ -857,46 +855,6 @@ module Gitlab
|
|||
submodule_data.select { |path, data| data['id'] }
|
||||
end
|
||||
|
||||
# Returns true if +commit+ introduced changes to +path+, using commit
|
||||
# trees to make that determination. Uses the history simplification
|
||||
# rules that `git log` uses by default, where a commit is omitted if it
|
||||
# is TREESAME to any parent.
|
||||
#
|
||||
# If the +follow+ option is true and the file specified by +path+ was
|
||||
# renamed, then the path value is set to the old path.
|
||||
def commit_touches_path?(commit, path, follow, walker)
|
||||
entry = tree_entry(commit, path)
|
||||
|
||||
if commit.parents.empty?
|
||||
# This is the root commit, return true if it has +path+ in its tree
|
||||
return !entry.nil?
|
||||
end
|
||||
|
||||
num_treesame = 0
|
||||
commit.parents.each do |parent|
|
||||
parent_entry = tree_entry(parent, path)
|
||||
|
||||
# Only follow the first TREESAME parent for merge commits
|
||||
if num_treesame > 0
|
||||
walker.hide(parent)
|
||||
next
|
||||
end
|
||||
|
||||
if entry.nil? && parent_entry.nil?
|
||||
num_treesame += 1
|
||||
elsif entry && parent_entry && entry[:oid] == parent_entry[:oid]
|
||||
num_treesame += 1
|
||||
end
|
||||
end
|
||||
|
||||
case num_treesame
|
||||
when 0
|
||||
detect_rename(commit, commit.parents.first, path) if follow
|
||||
true
|
||||
else false
|
||||
end
|
||||
end
|
||||
|
||||
# Find the entry for +path+ in the tree for +commit+
|
||||
def tree_entry(commit, path)
|
||||
pathname = Pathname.new(path)
|
||||
|
@ -924,43 +882,6 @@ module Gitlab
|
|||
tmp_entry
|
||||
end
|
||||
|
||||
# Compare +commit+ and +parent+ for +path+. If +path+ is a file and was
|
||||
# renamed in +commit+, then set +path+ to the old filename.
|
||||
def detect_rename(commit, parent, path)
|
||||
diff = parent.diff(commit, paths: [path], disable_pathspec_match: true)
|
||||
|
||||
# If +path+ is a filename, not a directory, then we should only have
|
||||
# one delta. We don't need to follow renames for directories.
|
||||
return nil if diff.each_delta.count > 1
|
||||
|
||||
delta = diff.each_delta.first
|
||||
if delta.added?
|
||||
full_diff = parent.diff(commit)
|
||||
full_diff.find_similar!
|
||||
|
||||
full_diff.each_delta do |full_delta|
|
||||
if full_delta.renamed? && path == full_delta.new_file[:path]
|
||||
# Look for the old path in ancestors
|
||||
path.replace(full_delta.old_file[:path])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if the index entry has the special file mode that denotes
|
||||
# a submodule.
|
||||
def submodule?(index_entry)
|
||||
index_entry[:mode] == 57344
|
||||
end
|
||||
|
||||
# Return a Rugged::Index that has read from the tree at +ref_name+
|
||||
def populated_index(ref_name)
|
||||
commit = rev_parse_target(ref_name)
|
||||
index = rugged.index
|
||||
index.read_tree(commit.tree)
|
||||
index
|
||||
end
|
||||
|
||||
# Return the Rugged patches for the diff between +from+ and +to+.
|
||||
def diff_patches(from, to, options = {}, *paths)
|
||||
options ||= {}
|
||||
|
|
|
@ -114,7 +114,7 @@ describe Gitlab::Git::Commit, seed_helper: true do
|
|||
describe '.find' do
|
||||
it "should return first head commit if without params" do
|
||||
expect(Gitlab::Git::Commit.last(repository).id).to eq(
|
||||
repository.raw.head.target.oid
|
||||
repository.rugged.head.target.oid
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
describe "Respond to" do
|
||||
subject { repository }
|
||||
|
||||
it { is_expected.to respond_to(:raw) }
|
||||
it { is_expected.to respond_to(:rugged) }
|
||||
it { is_expected.to respond_to(:root_ref) }
|
||||
it { is_expected.to respond_to(:tags) }
|
||||
|
@ -757,13 +756,13 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#commits_between" do
|
||||
describe "#rugged_commits_between" do
|
||||
context 'two SHAs' do
|
||||
let(:first_sha) { 'b0e52af38d7ea43cf41d8a6f2471351ac036d6c9' }
|
||||
let(:second_sha) { '0e50ec4d3c7ce42ab74dda1d422cb2cbffe1e326' }
|
||||
|
||||
it 'returns the number of commits between' do
|
||||
expect(repository.commits_between(first_sha, second_sha).count).to eq(3)
|
||||
expect(repository.rugged_commits_between(first_sha, second_sha).count).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -772,11 +771,11 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
let(:branch) { 'master' }
|
||||
|
||||
it 'returns the number of commits between a sha and a branch' do
|
||||
expect(repository.commits_between(sha, branch).count).to eq(5)
|
||||
expect(repository.rugged_commits_between(sha, branch).count).to eq(5)
|
||||
end
|
||||
|
||||
it 'returns the number of commits between a branch and a sha' do
|
||||
expect(repository.commits_between(branch, sha).count).to eq(0) # sha is before branch
|
||||
expect(repository.rugged_commits_between(branch, sha).count).to eq(0) # sha is before branch
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -785,7 +784,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
let(:second_branch) { 'master' }
|
||||
|
||||
it 'returns the number of commits between' do
|
||||
expect(repository.commits_between(first_branch, second_branch).count).to eq(17)
|
||||
expect(repository.rugged_commits_between(first_branch, second_branch).count).to eq(17)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue