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
1c458d17
Commit
1c458d17
authored
Dec 19, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move delete_remote_branches from Gitlab::Shell to Gitlab::Git::Repository
parent
43308bd8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
48 deletions
+81
-48
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+12
-0
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+0
-20
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+69
-0
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+0
-28
No files found.
lib/gitlab/git/repository.rb
View file @
1c458d17
...
...
@@ -1279,6 +1279,18 @@ module Gitlab
success
||
gitlab_projects_error
end
def
delete_remote_branches
(
remote_name
,
branch_names
)
success
=
@gitlab_projects
.
delete_remote_branches
(
remote_name
,
branch_names
)
success
||
gitlab_projects_error
end
def
delete_remote_branches
(
remote_name
,
branch_names
)
success
=
@gitlab_projects
.
delete_remote_branches
(
remote_name
,
branch_names
)
success
||
gitlab_projects_error
end
def
gitaly_repository
Gitlab
::
GitalyClient
::
Util
.
repository
(
@storage
,
@relative_path
,
@gl_repository
)
end
...
...
lib/gitlab/shell.rb
View file @
1c458d17
...
...
@@ -306,26 +306,6 @@ module Gitlab
end
end
# Delete branch from remote repository
#
# storage - project's storage path
# project_name - project's disk path
# remote_name - remote name
# branch_names - remote branch names
#
# Ex.
# delete_remote_branches('/path/to/storage', 'gitlab-org/gitlab-test', 'upstream', ['feature'])
#
def
delete_remote_branches
(
storage
,
project_name
,
remote_name
,
branch_names
)
cmd
=
gitlab_projects
(
storage
,
"
#{
project_name
}
.git"
)
success
=
cmd
.
delete_remote_branches
(
remote_name
,
branch_names
)
raise
Error
,
cmd
.
output
unless
success
success
end
protected
def
gitlab_shell_path
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
1c458d17
...
...
@@ -1918,6 +1918,75 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
,
'error'
)
end
end
describe
'#delete_remote_branches'
do
subject
do
repository
.
delete_remote_branches
(
'downstream-remote'
,
[
'master'
])
end
it
'executes the command'
do
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
true
)
is_expected
.
to
be_truthy
end
it
'raises an error if the command fails'
do
allow
(
gitlab_projects
).
to
receive
(
:output
)
{
'error'
}
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
false
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
,
'error'
)
end
end
describe
'#delete_remote_branches'
do
subject
do
repository
.
delete_remote_branches
(
'downstream-remote'
,
[
'master'
])
end
it
'executes the command'
do
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
true
)
is_expected
.
to
be_truthy
end
it
'raises an error if the command fails'
do
allow
(
gitlab_projects
).
to
receive
(
:output
)
{
'error'
}
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
false
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
,
'error'
)
end
end
describe
'#delete_remote_branches'
do
subject
do
repository
.
delete_remote_branches
(
'downstream-remote'
,
[
'master'
])
end
it
'executes the command'
do
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
true
)
is_expected
.
to
be_truthy
end
it
'raises an error if the command fails'
do
allow
(
gitlab_projects
).
to
receive
(
:output
)
{
'error'
}
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
false
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
,
'error'
)
end
end
end
def
create_remote_branch
(
repository
,
remote_name
,
branch_name
,
source_branch_name
)
...
...
spec/lib/gitlab/shell_spec.rb
View file @
1c458d17
...
...
@@ -347,34 +347,6 @@ describe Gitlab::Shell do
end
.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
"error"
)
end
end
describe
'#delete_remote_branches'
do
subject
(
:result
)
do
gitlab_shell
.
delete_remote_branches
(
project
.
repository_storage_path
,
project
.
disk_path
,
'downstream-remote'
,
[
'master'
]
)
end
it
'executes the command'
do
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
true
)
is_expected
.
to
be_truthy
end
it
'fails to execute the command'
do
allow
(
gitlab_projects
).
to
receive
(
:output
)
{
'error'
}
expect
(
gitlab_projects
).
to
receive
(
:delete_remote_branches
)
.
with
(
'downstream-remote'
,
[
'master'
])
.
and_return
(
false
)
expect
{
result
}.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
'error'
)
end
end
end
describe
'namespace actions'
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