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
c8abb527
Commit
c8abb527
authored
Jun 27, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Empty repository mirror no longer creates master branch with README automatically
parent
ceb63966
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
3 deletions
+32
-3
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+2
-2
app/services/projects/update_mirror_service.rb
app/services/projects/update_mirror_service.rb
+1
-1
changelogs/unreleased-ee/2425-fix-failure-for-mirrors-with-empty-repository.yml
...ee/2425-fix-failure-for-mirrors-with-empty-repository.yml
+4
-0
spec/services/projects/update_mirror_service_spec.rb
spec/services/projects/update_mirror_service_spec.rb
+25
-0
No files found.
app/services/create_branch_service.rb
View file @
c8abb527
class
CreateBranchService
<
BaseService
def
execute
(
branch_name
,
ref
)
create_master_branch
if
project
.
empty_repo?
def
execute
(
branch_name
,
ref
,
create_master_if_empty:
true
)
create_master_branch
if
create_master_if_empty
&&
project
.
empty_repo?
result
=
ValidateNewBranchService
.
new
(
project
,
current_user
)
.
execute
(
branch_name
)
...
...
app/services/projects/update_mirror_service.rb
View file @
c8abb527
...
...
@@ -36,7 +36,7 @@ module Projects
local_branch
=
local_branches
[
name
]
if
local_branch
.
nil?
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
name
,
upstream_branch
.
dereferenced_target
.
sha
)
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
name
,
upstream_branch
.
dereferenced_target
.
sha
,
create_master_if_empty:
false
)
if
result
[
:status
]
==
:error
errors
<<
result
[
:message
]
end
...
...
changelogs/unreleased-ee/2425-fix-failure-for-mirrors-with-empty-repository.yml
0 → 100644
View file @
c8abb527
---
title
:
Empty repository mirror no longer creates master branch with README automatically.
merge_request
:
2276
author
:
spec/services/projects/update_mirror_service_spec.rb
View file @
c8abb527
...
...
@@ -63,6 +63,31 @@ describe Projects::UpdateMirrorService do
expect
(
project
.
repository
.
find_branch
(
'markdown'
).
dereferenced_target
)
.
not_to
eq
(
project
.
repository
.
find_branch
(
'master'
).
dereferenced_target
)
end
describe
'when project is empty'
do
let
(
:project
)
{
create
(
:project_empty_repo
,
:mirror
,
import_url:
Project
::
UNKNOWN_IMPORT_URL
)
}
it
'does not add a default master branch'
do
repository
=
project
.
repository
allow
(
project
).
to
receive
(
:fetch_mirror
)
{
create_file
(
repository
)
}
expect
(
CreateBranchService
).
not_to
receive
(
:create_master_branch
)
described_class
.
new
(
project
,
project
.
owner
).
execute
expect
(
repository
.
branch_names
).
not_to
include
(
'master'
)
end
end
def
create_file
(
repository
)
repository
.
create_file
(
project
.
owner
,
'/newfile.txt'
,
'hello'
,
message:
'Add newfile.txt'
,
branch_name:
'newbranch'
)
end
end
describe
"when the mirror user doesn't have access"
do
...
...
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