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
iv
gitlab-ce
Commits
f44bd269
Commit
f44bd269
authored
May 27, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4072 from ndpgroup/import_w_groups
Include groups in import with import repos rake task
parents
b3bb5585
5f9d78fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
14 deletions
+38
-14
doc/raketasks/maintenance.md
doc/raketasks/maintenance.md
+5
-0
lib/tasks/gitlab/import.rake
lib/tasks/gitlab/import.rake
+33
-14
No files found.
doc/raketasks/maintenance.md
View file @
f44bd269
...
...
@@ -116,6 +116,8 @@ bundle exec rake gitlab:satellites:create RAILS_ENV=production
Notes:
*
project owner will be a first admin
*
groups will be created as needed
*
group owner will be the first admin
*
existing projects will be skipped
How to use:
...
...
@@ -132,5 +134,8 @@ Example output:
```
Processing abcd.git
* Created abcd (abcd.git)
Processing group/xyz.git
* Created Group group (2)
* Created xyz (group/xyz.git)
[...]
```
lib/tasks/gitlab/import.rake
View file @
f44bd269
...
...
@@ -13,42 +13,61 @@ namespace :gitlab do
task
repos: :environment
do
git_base_path
=
Gitlab
.
config
.
gitlab_shell
.
repos_path
repos_to_import
=
Dir
.
glob
(
git_base_path
+
'/*'
)
repos_to_import
=
Dir
.
glob
(
git_base_path
+
'/*
*/*.git
'
)
namespaces
=
Namespace
.
pluck
(
:path
)
repos_to_import
.
each
do
|
repo_path
|
repo_name
=
File
.
basename
repo_path
# strip repo base path
repo_path
[
0
..
git_base_path
.
length
]
=
''
# Skip if group or user
next
if
namespaces
.
include?
(
repo_name
)
path
=
repo_path
.
sub
(
/\.git$/
,
''
)
name
=
File
.
basename
path
group_name
=
File
.
dirname
path
group_name
=
nil
if
group_name
==
'.'
#
skip if not git repo
next
unless
repo_name
=~
/.git$/
#
Skip if group or user
next
if
namespaces
.
include?
(
name
)
next
if
repo_name
==
'gitolite-admin.git
'
next
if
name
==
'gitolite-admin
'
p
ath
=
repo_name
.
sub
(
/\.git$/
,
''
)
p
uts
"Processing
#{
repo_path
}
"
.
yellow
project
=
Project
.
find_with_namespace
(
path
)
puts
"Processing
#{
repo_name
}
"
.
yellow
if
project
puts
" *
#{
project
.
name
}
(
#{
repo_
name
}
) exists"
puts
" *
#{
project
.
name
}
(
#{
repo_
path
}
) exists"
else
user
=
User
.
admins
.
first
project_params
=
{
name:
path
,
name:
name
,
}
# find group namespace
if
group_name
group
=
Group
.
find_by_path
(
group_name
)
# create group namespace
if
!
group
group
=
Group
.
new
(
:name
=>
group_name
)
group
.
path
=
group_name
group
.
owner
=
user
if
group
.
save
puts
" * Created Group
#{
group
.
name
}
(
#{
group
.
id
}
)"
.
green
else
puts
" * Failed trying to create group
#{
group
.
name
}
"
.
red
end
end
# set project group
project_params
[
:namespace_id
]
=
group
.
id
end
project
=
Projects
::
CreateContext
.
new
(
user
,
project_params
).
execute
if
project
.
valid?
puts
" * Created
#{
project
.
name
}
(
#{
repo_
name
}
)"
.
green
puts
" * Created
#{
project
.
name
}
(
#{
repo_
path
}
)"
.
green
else
puts
" * Failed trying to create
#{
project
.
name
}
(
#{
repo_
name
}
)"
.
red
puts
" * Failed trying to create
#{
project
.
name
}
(
#{
repo_
path
}
)"
.
red
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