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
04b51a2b
Commit
04b51a2b
authored
Nov 25, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve activate_namespace task to build missing dirs and moving repos correctly
parent
fbe03c50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
lib/gitlab/backend/gitolite.rb
lib/gitlab/backend/gitolite.rb
+6
-0
lib/tasks/gitlab/activate_namespaces.rake
lib/tasks/gitlab/activate_namespaces.rake
+28
-4
No files found.
lib/gitlab/backend/gitolite.rb
View file @
04b51a2b
...
...
@@ -38,6 +38,12 @@ module Gitlab
config
.
admin_all_repo!
end
def
update_repositories
projects
config
.
apply
do
|
config
|
config
.
update_projects
(
projects
)
end
end
alias_method
:create_repository
,
:update_repository
end
end
lib/tasks/gitlab/activate_namespaces.rake
View file @
04b51a2b
namespace
:gitlab
do
desc
"GITLAB | Enable usernames and namespaces for user projects"
task
activate_namespaces: :environment
do
print
"
\n
Usernames for users:"
.
yellow
User
.
find_each
(
batch_size:
500
)
do
|
user
|
next
if
user
.
namespace
...
...
@@ -14,6 +16,8 @@ namespace :gitlab do
end
end
print
"
\n\n
Dirs for groups:"
.
yellow
Group
.
find_each
(
batch_size:
500
)
do
|
group
|
if
group
.
ensure_dir_exist
print
'.'
.
green
...
...
@@ -22,23 +26,43 @@ namespace :gitlab do
end
end
print
"
\n\n
Move projects from groups under groups dirs:"
.
yellow
git_path
=
Gitlab
.
config
.
git_base_path
Project
.
where
(
'namespace_id IS NOT NULL'
).
find_each
(
batch_size:
500
)
do
|
project
|
next
unless
project
.
group
next
if
project
.
empty_repo?
group
=
project
.
group
next
if
File
.
exists?
(
File
.
join
(
git_path
,
project
.
path_with_namespace
))
puts
"
\n
"
print
" *
#{
project
.
name
}
: "
new_path
=
File
.
join
(
git_path
,
project
.
path_with_namespace
+
'.git'
)
if
File
.
exists?
(
new_path
)
print
"ok. already at
#{
new_path
}
"
.
cyan
next
end
old_path
=
File
.
join
(
git_path
,
project
.
path
+
'.git'
)
next
unless
File
.
exists?
(
File
.
join
(
git_path
,
project
.
path
))
unless
File
.
exists?
(
old_path
)
print
"missing. not found at
#{
old_path
}
"
.
red
next
end
begin
Gitlab
::
ProjectMover
.
new
(
project
,
''
,
group
.
path
).
execute
print
'.'
.
green
print
"ok. Moved to
#{
new_path
}
"
.
green
rescue
print
'F'
.
red
print
"Failed moving to
#{
new_path
}
"
.
red
end
end
print
"
\n\n
Rebuild gitolite:"
.
yellow
gitolite
=
Gitlab
::
Gitolite
.
new
gitolite
.
update_repositories
(
Project
.
where
(
'namespace_id IS NOT NULL'
))
puts
"
\n
"
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