Commit fa8f8343745deb7b677a525d12dc69435a98ae21
1 parent
9f595aa4
Exists in
master
and in
4 other branches
Fix import rake task and tests
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
lib/tasks/gitlab/import.rake
| @@ -15,15 +15,20 @@ namespace :gitlab do | @@ -15,15 +15,20 @@ namespace :gitlab do | ||
| 15 | git_base_path = Gitlab.config.gitolite.repos_path | 15 | git_base_path = Gitlab.config.gitolite.repos_path |
| 16 | repos_to_import = Dir.glob(git_base_path + '/*') | 16 | repos_to_import = Dir.glob(git_base_path + '/*') |
| 17 | 17 | ||
| 18 | + namespaces = Namespace.pluck(:path) | ||
| 19 | + | ||
| 18 | repos_to_import.each do |repo_path| | 20 | repos_to_import.each do |repo_path| |
| 19 | repo_name = File.basename repo_path | 21 | repo_name = File.basename repo_path |
| 20 | 22 | ||
| 23 | + # Skip if group or user | ||
| 24 | + next if namespaces.include?(repo_name) | ||
| 25 | + | ||
| 21 | # skip gitolite admin | 26 | # skip gitolite admin |
| 22 | next if repo_name == 'gitolite-admin.git' | 27 | next if repo_name == 'gitolite-admin.git' |
| 23 | 28 | ||
| 24 | path = repo_name.sub(/\.git$/, '') | 29 | path = repo_name.sub(/\.git$/, '') |
| 25 | 30 | ||
| 26 | - project = Project.find_by_path(path) | 31 | + project = Project.find_with_namespace(path) |
| 27 | 32 | ||
| 28 | puts "Processing #{repo_name}".yellow | 33 | puts "Processing #{repo_name}".yellow |
| 29 | 34 | ||
| @@ -34,8 +39,6 @@ namespace :gitlab do | @@ -34,8 +39,6 @@ namespace :gitlab do | ||
| 34 | 39 | ||
| 35 | project_params = { | 40 | project_params = { |
| 36 | :name => path, | 41 | :name => path, |
| 37 | - :code => path, | ||
| 38 | - :path => path, | ||
| 39 | } | 42 | } |
| 40 | 43 | ||
| 41 | project = Project.create_by_user(project_params, user) | 44 | project = Project.create_by_user(project_params, user) |
spec/requests/api/projects_spec.rb
| @@ -64,6 +64,7 @@ describe Gitlab::API do | @@ -64,6 +64,7 @@ describe Gitlab::API do | ||
| 64 | post api("/projects", user), project | 64 | post api("/projects", user), project |
| 65 | 65 | ||
| 66 | project.each_pair do |k,v| | 66 | project.each_pair do |k,v| |
| 67 | + next if k == :path | ||
| 67 | json_response[k.to_s].should == v | 68 | json_response[k.to_s].should == v |
| 68 | end | 69 | end |
| 69 | end | 70 | end |