Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
9b216686
Commit
9b216686
authored
Aug 07, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gitaly-renames-annotations' into 'master'
Gitaly deletions and annotations See merge request !13280
parents
3a087a00
5d775ea3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
92 deletions
+12
-92
app/models/project.rb
app/models/project.rb
+1
-1
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+4
-83
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+1
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+5
-6
No files found.
app/models/project.rb
View file @
9b216686
...
...
@@ -941,7 +941,7 @@ class Project < ActiveRecord::Base
end
def
repo
repository
.
r
aw
repository
.
r
ugged
end
def
url_to_repo
...
...
lib/gitlab/git/commit.rb
View file @
9b216686
...
...
@@ -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
...
...
lib/gitlab/git/repository.rb
View file @
9b216686
...
...
@@ -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
||=
{}
...
...
spec/lib/gitlab/git/commit_spec.rb
View file @
9b216686
...
...
@@ -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
.
r
aw
.
head
.
target
.
oid
repository
.
r
ugged
.
head
.
target
.
oid
)
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
9b216686
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment