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
137594dd
Commit
137594dd
authored
Sep 07, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1339 from chopmann/fix-import_bulk
fix bulk_import for #1309
parents
5cb9e7ee
b3c8688d
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 @
137594dd
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
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"
imported_count
=
0
...
...
@@ -14,11 +12,9 @@ task :import_projects, [:email] => :environment do |t, args|
failed_count
=
0
repos_to_import
.
each
do
|
repo_path
|
repo_name
=
File
.
basename
repo_path
repo_full_path
=
File
.
join
(
Rails
.
root
,
repo_path
)
puts
" Processing
#{
repo_name
}
"
clone_path
=
"
#{
REPOSITORY_DIRECTORY
}
/
#{
repo_name
}
.git"
clone_path
=
"
#{
git_base_path
}#{
repo_name
}
.git"
if
Dir
.
exists?
clone_path
if
Project
.
find_by_code
(
repo_name
)
...
...
@@ -30,7 +26,7 @@ task :import_projects, [:email] => :environment do |t, args|
end
else
# 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
next
end
...
...
@@ -48,14 +44,17 @@ task :import_projects, [:email] => :environment do |t, args|
puts
"Finished importing
#{
imported_count
}
projects (skipped
#{
skipped_count
}
, failed
#{
failed_count
}
)."
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
)
git_user
=
Gitlab
.
config
.
ssh_user
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
rescue
rescue
Exception
=>
msg
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
...
...
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