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
24386ec7
Commit
24386ec7
authored
Sep 21, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port of 51725-push-mirrors-default-branch-reset-to-master to EE
parent
3c77a0b5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
42 deletions
+7
-42
app/models/project.rb
app/models/project.rb
+0
-6
app/models/repository.rb
app/models/repository.rb
+0
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+6
-0
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-34
No files found.
app/models/project.rb
View file @
24386ec7
...
...
@@ -2088,12 +2088,6 @@ class Project < ActiveRecord::Base
auto_cancel_pending_pipelines
==
'enabled'
end
# Update the default branch querying the remote to determine its HEAD
def
update_root_ref
(
remote_name
)
root_ref
=
repository
.
find_remote_root_ref
(
remote_name
)
change_head
(
root_ref
)
if
root_ref
.
present?
&&
root_ref
!=
default_branch
end
private
# rubocop: disable CodeReuse/ServiceClass
...
...
app/models/repository.rb
View file @
24386ec7
...
...
@@ -29,7 +29,6 @@ class Repository
delegate
:ref_name_for_sha
,
to: :raw_repository
delegate
:bundle_to_disk
,
to: :raw_repository
delegate
:find_remote_root_ref
,
to: :raw_repository
CreateTreeError
=
Class
.
new
(
StandardError
)
...
...
ee/app/models/ee/project.rb
View file @
24386ec7
...
...
@@ -549,6 +549,12 @@ module EE
end
end
# Update the default branch querying the remote to determine its HEAD
def
update_root_ref
(
remote_name
)
root_ref
=
repository
.
find_remote_root_ref
(
remote_name
)
change_head
(
root_ref
)
if
root_ref
.
present?
&&
root_ref
!=
default_branch
end
private
def
set_override_pull_mirror_available
...
...
ee/app/models/ee/repository.rb
View file @
24386ec7
...
...
@@ -10,7 +10,7 @@ module EE
MIRROR_REMOTE
=
"upstream"
.
freeze
prepended
do
delegate
:checksum
,
to: :raw_repository
delegate
:checksum
,
:find_remote_root_ref
,
to: :raw_repository
end
# Transiently sets a configuration variable
...
...
spec/models/project_spec.rb
View file @
24386ec7
...
...
@@ -4298,40 +4298,6 @@ describe Project do
end
end
describe
'#update_root_ref'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
it
'updates the default branch when HEAD has changed'
do
stub_find_remote_root_ref
(
project
,
ref:
'feature'
)
expect
{
project
.
update_root_ref
(
'origin'
)
}
.
to
change
{
project
.
default_branch
}
.
from
(
'master'
)
.
to
(
'feature'
)
end
it
'does not update the default branch when HEAD does not change'
do
stub_find_remote_root_ref
(
project
,
ref:
'master'
)
expect
{
project
.
update_root_ref
(
'origin'
)
}
.
not_to
change
{
project
.
default_branch
}
end
it
'does not update the default branch when HEAD does not exist'
do
stub_find_remote_root_ref
(
project
,
ref:
'foo'
)
expect
{
project
.
update_root_ref
(
'origin'
)
}
.
not_to
change
{
project
.
default_branch
}
end
def
stub_find_remote_root_ref
(
project
,
ref
:)
allow
(
project
.
repository
)
.
to
receive
(
:find_remote_root_ref
)
.
with
(
'origin'
)
.
and_return
(
ref
)
end
end
def
rugged_config
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
project
.
repository
.
rugged
.
config
...
...
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