diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-15 23:40:35 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-15 23:40:35 +0300 |
commit | e21deaee8ee0d453bf899c1b3fb46262cc60dab9 (patch) | |
tree | 59b04c9cb1c8ce6c510a78ee787fb31817619835 /app/models | |
parent | 7e2dbcbe0915cfd75e91d78e943c153f284df37d (diff) | |
parent | 0ad669bb5ba08d012d3daa50b51a3a6b069e3e83 (diff) |
Merge remote-tracking branch 'origin/master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
# Conflicts:
# Gemfile.lock
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 24 | ||||
-rw-r--r-- | app/models/project_services/slack_service.rb | 6 |
2 files changed, 20 insertions, 10 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 495a863d93b..81951467d41 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -144,7 +144,7 @@ class Project < ActiveRecord::Base validates_uniqueness_of :path, scope: :namespace_id validates :import_url, format: { with: /\A#{URI.regexp(%w(ssh git http https))}\z/, message: 'should be a valid url' }, - if: :import? + if: :external_import? validates :star_count, numericality: { greater_than_or_equal_to: 0 } validate :check_limit, on: :create validate :avatar_type, @@ -275,7 +275,13 @@ class Project < ActiveRecord::Base end def add_import_job - RepositoryImportWorker.perform_in(2.seconds, id) + if forked? + unless RepositoryForkWorker.perform_async(id, forked_from_project.path_with_namespace, self.namespace.path) + import_fail + end + else + RepositoryImportWorker.perform_in(2.seconds, id) + end end def clear_import_data @@ -283,6 +289,10 @@ class Project < ActiveRecord::Base end def import? + external_import? || forked? + end + + def external_import? import_url.present? end @@ -702,14 +712,8 @@ class Project < ActiveRecord::Base end def create_repository - if forked? - if gitlab_shell.fork_repository(forked_from_project.path_with_namespace, self.namespace.path) - true - else - errors.add(:base, 'Failed to fork repository via gitlab-shell') - false - end - else + # Forked import is handled asynchronously + unless forked? if gitlab_shell.add_repository(path_with_namespace) true else diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 36d9874edd3..7cd5e892507 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -34,6 +34,12 @@ class SlackService < Service 'slack' end + def help + 'This service sends notifications to your Slack channel.<br/> + To setup this Service you need to create a new <b>"Incoming webhook"</b> in your Slack integration panel, + and enter the Webhook URL below.' + end + def fields [ { type: 'text', name: 'webhook', |