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
87467127
Commit
87467127
authored
Aug 24, 2017
by
Maxim Rydkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace `is_ancestor?` with `ancestor?`
parent
5f72aaa3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
app/models/deployment.rb
app/models/deployment.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+3
-3
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+11
-11
No files found.
app/models/deployment.rb
View file @
87467127
...
...
@@ -49,7 +49,7 @@ class Deployment < ActiveRecord::Base
# created before then could have a `sha` referring to a commit that no
# longer exists in the repository, so just ignore those.
begin
project
.
repository
.
is_
ancestor?
(
commit
.
id
,
sha
)
project
.
repository
.
ancestor?
(
commit
.
id
,
sha
)
rescue
Rugged
::
OdbError
false
end
...
...
app/models/repository.rb
View file @
87467127
...
...
@@ -944,7 +944,7 @@ class Repository
if
branch_commit
same_head
=
branch_commit
.
id
==
root_ref_commit
.
id
!
same_head
&&
is_
ancestor?
(
branch_commit
.
id
,
root_ref_commit
.
id
)
!
same_head
&&
ancestor?
(
branch_commit
.
id
,
root_ref_commit
.
id
)
else
nil
end
...
...
@@ -958,12 +958,12 @@ class Repository
nil
end
def
is_
ancestor?
(
ancestor_id
,
descendant_id
)
def
ancestor?
(
ancestor_id
,
descendant_id
)
return
false
if
ancestor_id
.
nil?
||
descendant_id
.
nil?
Gitlab
::
GitalyClient
.
migrate
(
:is_ancestor
)
do
|
is_enabled
|
if
is_enabled
raw_repository
.
is_
ancestor?
(
ancestor_id
,
descendant_id
)
raw_repository
.
ancestor?
(
ancestor_id
,
descendant_id
)
else
rugged_is_ancestor?
(
ancestor_id
,
descendant_id
)
end
...
...
lib/gitlab/git/repository.rb
View file @
87467127
...
...
@@ -439,7 +439,7 @@ module Gitlab
end
# Returns true is +from+ is direct ancestor to +to+, otherwise false
def
is_
ancestor?
(
from
,
to
)
def
ancestor?
(
from
,
to
)
gitaly_commit_client
.
is_ancestor
(
from
,
to
)
end
...
...
spec/models/repository_spec.rb
View file @
87467127
...
...
@@ -2036,23 +2036,23 @@ describe Repository, models: true do
end
end
describe
'#
is_
ancestor?'
do
describe
'#ancestor?'
do
let
(
:commit
)
{
repository
.
commit
}
let
(
:ancestor
)
{
commit
.
parents
.
first
}
context
'with Gitaly enabled'
do
it
'it is an ancestor'
do
expect
(
repository
.
is_
ancestor?
(
ancestor
.
id
,
commit
.
id
)).
to
eq
(
true
)
expect
(
repository
.
ancestor?
(
ancestor
.
id
,
commit
.
id
)).
to
eq
(
true
)
end
it
'it is not an ancestor'
do
expect
(
repository
.
is_
ancestor?
(
commit
.
id
,
ancestor
.
id
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
commit
.
id
,
ancestor
.
id
)).
to
eq
(
false
)
end
it
'returns false on nil-values'
do
expect
(
repository
.
is_
ancestor?
(
nil
,
commit
.
id
)).
to
eq
(
false
)
expect
(
repository
.
is_
ancestor?
(
ancestor
.
id
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
is_
ancestor?
(
nil
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
nil
,
commit
.
id
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
ancestor
.
id
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
nil
,
nil
)).
to
eq
(
false
)
end
end
...
...
@@ -2063,17 +2063,17 @@ describe Repository, models: true do
end
it
'it is an ancestor'
do
expect
(
repository
.
is_
ancestor?
(
ancestor
.
id
,
commit
.
id
)).
to
eq
(
true
)
expect
(
repository
.
ancestor?
(
ancestor
.
id
,
commit
.
id
)).
to
eq
(
true
)
end
it
'it is not an ancestor'
do
expect
(
repository
.
is_
ancestor?
(
commit
.
id
,
ancestor
.
id
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
commit
.
id
,
ancestor
.
id
)).
to
eq
(
false
)
end
it
'returns false on nil-values'
do
expect
(
repository
.
is_
ancestor?
(
nil
,
commit
.
id
)).
to
eq
(
false
)
expect
(
repository
.
is_
ancestor?
(
ancestor
.
id
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
is_
ancestor?
(
nil
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
nil
,
commit
.
id
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
ancestor
.
id
,
nil
)).
to
eq
(
false
)
expect
(
repository
.
ancestor?
(
nil
,
nil
)).
to
eq
(
false
)
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