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
366dd546
Commit
366dd546
authored
Jun 29, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log the renamed event to the Geo event log when renaming a repository
parent
05fca188
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
app/models/ee/project.rb
app/models/ee/project.rb
+12
-0
spec/models/ee/project_spec.rb
spec/models/ee/project_spec.rb
+33
-0
No files found.
app/models/ee/project.rb
View file @
366dd546
...
...
@@ -425,6 +425,18 @@ module EE
end
alias_method
:merge_requests_ff_only_enabled?
,
:merge_requests_ff_only_enabled
def
rename_repo
raise
NotImplementedError
unless
defined?
(
super
)
super
path_was
=
previous_changes
[
'path'
].
first
old_path_with_namespace
=
File
.
join
(
namespace
.
full_path
,
path_was
)
::
Geo
::
RepositoryRenamedEventStore
.
new
(
self
,
old_path:
path_was
,
old_path_with_namespace:
old_path_with_namespace
).
create
end
private
def
licensed_feature_available?
(
feature
)
...
...
spec/models/ee/project_spec.rb
View file @
366dd546
...
...
@@ -604,4 +604,37 @@ describe Project, models: true do
end
end
end
describe
'#rename_repo'
do
context
'when running on a primary node'
do
let!
(
:geo_node
)
{
create
(
:geo_node
,
:primary
,
:current
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
before
do
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
allow
(
project
).
to
receive
(
:previous_changes
).
and_return
(
'path'
=>
[
'foo'
])
end
it
'logs the Geo::RepositoryRenamedEvent'
do
stub_container_registry_config
(
enabled:
false
)
allow
(
gitlab_shell
).
to
receive
(
:mv_repository
)
.
ordered
.
with
(
project
.
repository_storage_path
,
"
#{
project
.
namespace
.
full_path
}
/foo"
,
"
#{
project
.
full_path
}
"
)
.
and_return
(
true
)
allow
(
gitlab_shell
).
to
receive
(
:mv_repository
)
.
ordered
.
with
(
project
.
repository_storage_path
,
"
#{
project
.
namespace
.
full_path
}
/foo.wiki"
,
"
#{
project
.
full_path
}
.wiki"
)
.
and_return
(
true
)
expect
(
Geo
::
RepositoryRenamedEventStore
).
to
receive
(
:new
)
.
with
(
instance_of
(
Project
),
old_path:
'foo'
,
old_path_with_namespace:
"
#{
project
.
namespace
.
full_path
}
/foo"
)
.
and_call_original
expect
{
project
.
rename_repo
}.
to
change
(
Geo
::
RepositoryRenamedEvent
,
:count
).
by
(
1
)
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