Add imported boolean to project. Prevent shell from creating repo after it was imported

This commit is contained in:
Dmitriy Zaporozhets 2013-06-14 16:30:48 +03:00
parent da98cebc5b
commit e7c930a55b
6 changed files with 20 additions and 9 deletions

View file

@ -51,6 +51,7 @@ module Projects
if shell.import_repository(@project.path_with_namespace, @project.import_url)
# We should create satellite for imported repo
@project.satellite.create unless @project.satellite.exists?
@project.imported = true
true
else
@project.errors.add(:import_url, 'cannot clone repo')

View file

@ -142,7 +142,7 @@ module ApplicationHelper
end
def user_color_scheme_class
COLOR_SCHEMES[current_user.try(:color_scheme_id)]
COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user)
end
# Define whenever show last push event

View file

@ -413,6 +413,10 @@ class Project < ActiveRecord::Base
!(forked_project_link.nil? || forked_project_link.forked_from_project.nil?)
end
def imported?
imported
end
def rename_repo
old_path_with_namespace = File.join(namespace_dir, path_was)
new_path_with_namespace = File.join(namespace_dir, path)

View file

@ -1,13 +1,13 @@
class ProjectObserver < BaseObserver
def after_create(project)
unless project.forked?
GitlabShellWorker.perform_async(
:add_repository,
project.path_with_namespace
)
return true if project.forked? || project.imported?
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end
GitlabShellWorker.perform_async(
:add_repository,
project.path_with_namespace
)
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end
def after_update(project)

View file

@ -0,0 +1,5 @@
class AddImprotedToProject < ActiveRecord::Migration
def change
add_column :projects, :imported, :boolean, default: false, null: false
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130613173246) do
ActiveRecord::Schema.define(:version => 20130614132337) do
create_table "deploy_keys_projects", :force => true do |t|
t.integer "deploy_key_id", :null => false
@ -172,6 +172,7 @@ ActiveRecord::Schema.define(:version => 20130613173246) do
t.string "issues_tracker_id"
t.boolean "snippets_enabled", :default => true, :null => false
t.datetime "last_activity_at"
t.boolean "imported", :default => false, :null => false
end
add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id"