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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
acf84bb1
Commit
acf84bb1
authored
Oct 11, 2019
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor diverged check
parent
8e4e0631
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
18 deletions
+16
-18
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+16
-18
No files found.
ee/app/models/ee/repository.rb
View file @
acf84bb1
...
...
@@ -60,24 +60,14 @@ module EE
upstream_branch
=
upstream_branch_name
(
branch_name
)
return
false
unless
upstream_branch
branch_commit
=
commit
(
"refs/heads/
#{
branch_name
}
"
)
upstream_commit
=
commit
(
"refs/remotes/
#{
MIRROR_REMOTE
}
/
#{
upstream_branch
}
"
)
if
branch_commit
&&
upstream_commit
diverged?
(
branch_name
,
MIRROR_REMOTE
,
upstream_branch_name:
upstream_branch
)
do
|
branch_commit
,
upstream_commit
|
!
raw_repository
.
ancestor?
(
branch_commit
.
id
,
upstream_commit
.
id
)
else
false
end
end
def
upstream_has_diverged?
(
branch_name
,
remote_ref
)
branch_commit
=
commit
(
"refs/heads/
#{
branch_name
}
"
)
upstream_commit
=
commit
(
"refs/remotes/
#{
remote_ref
}
/
#{
branch_name
}
"
)
if
branch_commit
&&
upstream_commit
diverged?
(
branch_name
,
remote_ref
)
do
|
branch_commit
,
upstream_commit
|
!
raw_repository
.
ancestor?
(
upstream_commit
.
id
,
branch_commit
.
id
)
else
false
end
end
...
...
@@ -85,13 +75,8 @@ module EE
upstream_branch
=
upstream_branch_name
(
branch_name
)
return
false
unless
upstream_branch
branch_commit
=
commit
(
"refs/heads/
#{
branch_name
}
"
)
upstream_commit
=
commit
(
"refs/remotes/
#{
MIRROR_REMOTE
}
/
#{
upstream_branch
}
"
)
if
branch_commit
&&
upstream_commit
diverged?
(
branch_name
,
MIRROR_REMOTE
,
upstream_branch_name:
upstream_branch
)
do
|
branch_commit
,
upstream_commit
|
ancestor?
(
branch_commit
.
id
,
upstream_commit
.
id
)
else
false
end
end
...
...
@@ -123,5 +108,18 @@ module EE
def
insights_config_for
(
sha
)
blob_data_at
(
sha
,
::
Gitlab
::
Insights
::
CONFIG_FILE_PATH
)
end
private
def
diverged?
(
branch_name
,
remote_ref
,
upstream_branch_name:
branch_name
)
branch_commit
=
commit
(
"refs/heads/
#{
branch_name
}
"
)
upstream_commit
=
commit
(
"refs/remotes/
#{
remote_ref
}
/
#{
upstream_branch_name
}
"
)
if
branch_commit
&&
upstream_commit
yield
branch_commit
,
upstream_commit
else
false
end
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