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
b3c8688d
Commit
b3c8688d
authored
Aug 30, 2012
by
Cornelio
Committed by
Hopmann, Cornelio
Sep 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bulk_import for #1309
parent
e4447de2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
lib/tasks/bulk_import.rake
lib/tasks/bulk_import.rake
+14
-15
No files found.
lib/tasks/bulk_import.rake
View file @
b3c8688d
IMPORT_DIRECTORY
=
'import_projects'
desc
"Imports existing Git repos into new projects from the import_projects folder"
task
:import_projects
,
[
:email
]
=>
:environment
do
|
t
,
args
|
REPOSITORY_DIRECTORY
=
Gitlab
.
config
.
git_base_path
desc
"Imports existing Git repos from a directory into new projects in git_base_path"
task
:import_projects
,
[
:directory
,
:email
]
=>
:environment
do
|
t
,
args
|
user_email
=
args
.
email
user_email
=
args
.
email
repos_to_import
=
Dir
.
glob
(
"
#{
IMPORT_DIRECTORY
}
/*"
)
import_directory
=
args
.
directory
repos_to_import
=
Dir
.
glob
(
"
#{
import_directory
}
/*"
)
git_base_path
=
Gitlab
.
config
.
git_base_path
puts
"Found
#{
repos_to_import
.
length
}
repos to import"
puts
"Found
#{
repos_to_import
.
length
}
repos to import"
imported_count
=
0
imported_count
=
0
...
@@ -14,11 +12,9 @@ task :import_projects, [:email] => :environment do |t, args|
...
@@ -14,11 +12,9 @@ task :import_projects, [:email] => :environment do |t, args|
failed_count
=
0
failed_count
=
0
repos_to_import
.
each
do
|
repo_path
|
repos_to_import
.
each
do
|
repo_path
|
repo_name
=
File
.
basename
repo_path
repo_name
=
File
.
basename
repo_path
repo_full_path
=
File
.
join
(
Rails
.
root
,
repo_path
)
puts
" Processing
#{
repo_name
}
"
puts
" Processing
#{
repo_name
}
"
clone_path
=
"
#{
git_base_path
}#{
repo_name
}
.git"
clone_path
=
"
#{
REPOSITORY_DIRECTORY
}
/
#{
repo_name
}
.git"
if
Dir
.
exists?
clone_path
if
Dir
.
exists?
clone_path
if
Project
.
find_by_code
(
repo_name
)
if
Project
.
find_by_code
(
repo_name
)
...
@@ -30,7 +26,7 @@ task :import_projects, [:email] => :environment do |t, args|
...
@@ -30,7 +26,7 @@ task :import_projects, [:email] => :environment do |t, args|
end
end
else
else
# Clone the repo
# Clone the repo
unless
clone_bare_repo_as_git
(
repo_
full_
path
,
clone_path
)
unless
clone_bare_repo_as_git
(
repo_path
,
clone_path
)
failed_count
+=
1
failed_count
+=
1
next
next
end
end
...
@@ -48,14 +44,17 @@ task :import_projects, [:email] => :environment do |t, args|
...
@@ -48,14 +44,17 @@ task :import_projects, [:email] => :environment do |t, args|
puts
"Finished importing
#{
imported_count
}
projects (skipped
#{
skipped_count
}
, failed
#{
failed_count
}
)."
puts
"Finished importing
#{
imported_count
}
projects (skipped
#{
skipped_count
}
, failed
#{
failed_count
}
)."
end
end
# Clones a repo as bare git repo using the git
user
# Clones a repo as bare git repo using the git
_
user
def
clone_bare_repo_as_git
(
existing_path
,
new_path
)
def
clone_bare_repo_as_git
(
existing_path
,
new_path
)
git_user
=
Gitlab
.
config
.
ssh_user
begin
begin
sh
"sudo -u
git
-i git clone --bare '
#{
existing_path
}
'
#{
new_path
}
"
sh
"sudo -u
#{
git_user
}
-i git clone --bare '
#{
existing_path
}
'
#{
new_path
}
"
true
true
rescue
rescue
Exception
=>
msg
puts
" ERROR: Faild to clone
#{
existing_path
}
to
#{
new_path
}
"
puts
" ERROR: Faild to clone
#{
existing_path
}
to
#{
new_path
}
"
false
puts
" Make sure
#{
git_user
}
can reach
#{
existing_path
}
"
puts
" Exception-MSG:
#{
msg
}
"
false
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