Commit e7c930a5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

parent da98cebc
...@@ -51,6 +51,7 @@ module Projects ...@@ -51,6 +51,7 @@ module Projects
if shell.import_repository(@project.path_with_namespace, @project.import_url) if shell.import_repository(@project.path_with_namespace, @project.import_url)
# We should create satellite for imported repo # We should create satellite for imported repo
@project.satellite.create unless @project.satellite.exists? @project.satellite.create unless @project.satellite.exists?
@project.imported = true
true true
else else
@project.errors.add(:import_url, 'cannot clone repo') @project.errors.add(:import_url, 'cannot clone repo')
......
...@@ -142,7 +142,7 @@ module ApplicationHelper ...@@ -142,7 +142,7 @@ module ApplicationHelper
end end
def user_color_scheme_class 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 end
# Define whenever show last push event # Define whenever show last push event
......
...@@ -413,6 +413,10 @@ class Project < ActiveRecord::Base ...@@ -413,6 +413,10 @@ class Project < ActiveRecord::Base
!(forked_project_link.nil? || forked_project_link.forked_from_project.nil?) !(forked_project_link.nil? || forked_project_link.forked_from_project.nil?)
end end
def imported?
imported
end
def rename_repo def rename_repo
old_path_with_namespace = File.join(namespace_dir, path_was) old_path_with_namespace = File.join(namespace_dir, path_was)
new_path_with_namespace = File.join(namespace_dir, path) new_path_with_namespace = File.join(namespace_dir, path)
......
class ProjectObserver < BaseObserver class ProjectObserver < BaseObserver
def after_create(project) def after_create(project)
unless project.forked? return true if project.forked? || project.imported?
GitlabShellWorker.perform_async(
:add_repository, GitlabShellWorker.perform_async(
project.path_with_namespace :add_repository,
) project.path_with_namespace
)
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end end
def after_update(project) def after_update(project)
......
class AddImprotedToProject < ActiveRecord::Migration
def change
add_column :projects, :imported, :boolean, default: false, null: false
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "deploy_keys_projects", :force => true do |t|
t.integer "deploy_key_id", :null => false 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
t.string "issues_tracker_id" t.string "issues_tracker_id"
t.boolean "snippets_enabled", :default => true, :null => false t.boolean "snippets_enabled", :default => true, :null => false
t.datetime "last_activity_at" t.datetime "last_activity_at"
t.boolean "imported", :default => false, :null => false
end end
add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment