Commit e7c930a55b9832a767bfb1a5e2a8add8f9e719f9
1 parent
da98cebc
Exists in
master
and in
4 other branches
Add imported boolean to project. Prevent shell from creating repo after it was imported
Showing
6 changed files
with
21 additions
and
10 deletions
Show diff stats
app/contexts/projects/create_context.rb
@@ -51,6 +51,7 @@ module Projects | @@ -51,6 +51,7 @@ module Projects | ||
51 | if shell.import_repository(@project.path_with_namespace, @project.import_url) | 51 | if shell.import_repository(@project.path_with_namespace, @project.import_url) |
52 | # We should create satellite for imported repo | 52 | # We should create satellite for imported repo |
53 | @project.satellite.create unless @project.satellite.exists? | 53 | @project.satellite.create unless @project.satellite.exists? |
54 | + @project.imported = true | ||
54 | true | 55 | true |
55 | else | 56 | else |
56 | @project.errors.add(:import_url, 'cannot clone repo') | 57 | @project.errors.add(:import_url, 'cannot clone repo') |
app/helpers/application_helper.rb
@@ -142,7 +142,7 @@ module ApplicationHelper | @@ -142,7 +142,7 @@ module ApplicationHelper | ||
142 | end | 142 | end |
143 | 143 | ||
144 | def user_color_scheme_class | 144 | def user_color_scheme_class |
145 | - COLOR_SCHEMES[current_user.try(:color_scheme_id)] | 145 | + COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user) |
146 | end | 146 | end |
147 | 147 | ||
148 | # Define whenever show last push event | 148 | # Define whenever show last push event |
app/models/project.rb
@@ -413,6 +413,10 @@ class Project < ActiveRecord::Base | @@ -413,6 +413,10 @@ class Project < ActiveRecord::Base | ||
413 | !(forked_project_link.nil? || forked_project_link.forked_from_project.nil?) | 413 | !(forked_project_link.nil? || forked_project_link.forked_from_project.nil?) |
414 | end | 414 | end |
415 | 415 | ||
416 | + def imported? | ||
417 | + imported | ||
418 | + end | ||
419 | + | ||
416 | def rename_repo | 420 | def rename_repo |
417 | old_path_with_namespace = File.join(namespace_dir, path_was) | 421 | old_path_with_namespace = File.join(namespace_dir, path_was) |
418 | new_path_with_namespace = File.join(namespace_dir, path) | 422 | new_path_with_namespace = File.join(namespace_dir, path) |
app/observers/project_observer.rb
1 | class ProjectObserver < BaseObserver | 1 | class ProjectObserver < BaseObserver |
2 | def after_create(project) | 2 | def after_create(project) |
3 | - unless project.forked? | ||
4 | - GitlabShellWorker.perform_async( | ||
5 | - :add_repository, | ||
6 | - project.path_with_namespace | ||
7 | - ) | ||
8 | - | ||
9 | - log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") | ||
10 | - end | 3 | + return true if project.forked? || project.imported? |
4 | + | ||
5 | + GitlabShellWorker.perform_async( | ||
6 | + :add_repository, | ||
7 | + project.path_with_namespace | ||
8 | + ) | ||
9 | + | ||
10 | + log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") | ||
11 | end | 11 | end |
12 | 12 | ||
13 | def after_update(project) | 13 | def after_update(project) |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20130613173246) do | 14 | +ActiveRecord::Schema.define(:version => 20130614132337) do |
15 | 15 | ||
16 | create_table "deploy_keys_projects", :force => true do |t| | 16 | create_table "deploy_keys_projects", :force => true do |t| |
17 | t.integer "deploy_key_id", :null => false | 17 | t.integer "deploy_key_id", :null => false |
@@ -172,6 +172,7 @@ ActiveRecord::Schema.define(:version => 20130613173246) do | @@ -172,6 +172,7 @@ ActiveRecord::Schema.define(:version => 20130613173246) do | ||
172 | t.string "issues_tracker_id" | 172 | t.string "issues_tracker_id" |
173 | t.boolean "snippets_enabled", :default => true, :null => false | 173 | t.boolean "snippets_enabled", :default => true, :null => false |
174 | t.datetime "last_activity_at" | 174 | t.datetime "last_activity_at" |
175 | + t.boolean "imported", :default => false, :null => false | ||
175 | end | 176 | end |
176 | 177 | ||
177 | add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" | 178 | add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" |