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
Léo-Paul Géneau
gitlab-ce
Commits
a87fccc0
Commit
a87fccc0
authored
Dec 24, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update projects in gitolite after namespace moved. Added rake task to cleanup garbage from gitolite
parent
dea86281
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
app/models/namespace.rb
app/models/namespace.rb
+11
-0
app/roles/namespaced_project.rb
app/roles/namespaced_project.rb
+1
-1
lib/tasks/gitlab/gitolite_rebuild.rake
lib/tasks/gitlab/gitolite_rebuild.rake
+33
-0
No files found.
app/models/namespace.rb
View file @
a87fccc0
...
@@ -27,10 +27,13 @@ class Namespace < ActiveRecord::Base
...
@@ -27,10 +27,13 @@ class Namespace < ActiveRecord::Base
after_create
:ensure_dir_exist
after_create
:ensure_dir_exist
after_update
:move_dir
after_update
:move_dir
after_commit
:update_gitolite
,
on: :update
,
if: :require_update_gitolite
after_destroy
:rm_dir
after_destroy
:rm_dir
scope
:root
,
where
(
'type IS NULL'
)
scope
:root
,
where
(
'type IS NULL'
)
attr_accessor
:require_update_gitolite
def
self
.
search
query
def
self
.
search
query
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
end
...
@@ -62,10 +65,18 @@ class Namespace < ActiveRecord::Base
...
@@ -62,10 +65,18 @@ class Namespace < ActiveRecord::Base
if
system
(
"mv
#{
old_path
}
#{
new_path
}
"
)
if
system
(
"mv
#{
old_path
}
#{
new_path
}
"
)
send_update_instructions
send_update_instructions
@require_update_gitolite
=
true
else
raise
"Namespace move error
#{
old_path
}
#{
new_path
}
"
end
end
end
end
end
end
def
update_gitolite
@require_update_gitolite
=
false
projects
.
each
(
&
:update_repository
)
end
def
rm_dir
def
rm_dir
dir_path
=
File
.
join
(
Gitlab
.
config
.
gitolite
.
repos_path
,
path
)
dir_path
=
File
.
join
(
Gitlab
.
config
.
gitolite
.
repos_path
,
path
)
system
(
"rm -rf
#{
dir_path
}
"
)
system
(
"rm -rf
#{
dir_path
}
"
)
...
...
app/roles/namespaced_project.rb
View file @
a87fccc0
...
@@ -24,7 +24,7 @@ module NamespacedProject
...
@@ -24,7 +24,7 @@ module NamespacedProject
save!
save!
end
end
rescue
Gitlab
::
ProjectMover
::
ProjectMoveError
=>
ex
rescue
Gitlab
::
ProjectMover
::
ProjectMoveError
=>
ex
raise
TransferError
.
new
(
ex
.
message
)
raise
Project
::
TransferError
.
new
(
ex
.
message
)
end
end
def
name_with_namespace
def
name_with_namespace
...
...
lib/tasks/gitlab/gitolite_rebuild.rake
View file @
a87fccc0
...
@@ -23,5 +23,38 @@ namespace :gitlab do
...
@@ -23,5 +23,38 @@ namespace :gitlab do
puts
"...
#{
"done"
.
green
}
"
puts
"...
#{
"done"
.
green
}
"
end
end
end
end
desc
"GITLAB | Cleanup gitolite config"
task
:cleanup
=>
:environment
do
warn_user_is_not_gitlab
real_repos
=
Project
.
all
.
map
(
&
:path_with_namespace
)
real_repos
<<
"gitolite-admin"
real_repos
<<
"@all"
remove_flag
=
ENV
[
'REMOVE'
]
puts
"Looking for repositories to remove... "
Gitlab
::
GitoliteConfig
.
new
.
apply
do
|
config
|
all_repos
=
[]
garbage_repos
=
[]
all_repos
=
config
.
conf
.
repos
.
keys
garbage_repos
=
all_repos
-
real_repos
garbage_repos
.
each
do
|
repo_name
|
if
remove_flag
config
.
conf
.
rm_repo
(
repo_name
)
print
"to remove..."
.
red
end
puts
repo_name
.
red
end
end
unless
remove_flag
puts
"To cleanup repositories run this command with REMOVE=true"
.
yellow
end
end
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