Commit d21d5d2d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'import-event' into 'master'

Add event to activity feed for imported projects.

![Screen_Shot_2015-04-06_at_14.51.16](https://gitlab.com/gitlab-org/gitlab-ce/uploads/07fd16cb558873d2a6fb6c3cfcfdb227/Screen_Shot_2015-04-06_at_14.51.16.png)

See merge request !496
parents 526b28da 4740242a
...@@ -8,7 +8,7 @@ class Import::BaseController < ApplicationController ...@@ -8,7 +8,7 @@ class Import::BaseController < ApplicationController
namespace.add_owner(current_user) namespace.add_owner(current_user)
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
namespace = Namespace.find_by_path_or_name(@target_namespace) namespace = Namespace.find_by_path_or_name(@target_namespace)
unless namespace.owner == current_user unless current_user.can?(:create_projects, namespace)
@already_been_taken = true @already_been_taken = true
return false return false
end end
......
...@@ -183,7 +183,11 @@ class Event < ActiveRecord::Base ...@@ -183,7 +183,11 @@ class Event < ActiveRecord::Base
elsif commented? elsif commented?
"commented on" "commented on"
elsif created_project? elsif created_project?
"created" if project.import?
"imported"
else
"created"
end
else else
"opened" "opened"
end end
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
%a.twitter-share-button{ | %a.twitter-share-button{ |
href: "https://twitter.com/share", | href: "https://twitter.com/share", |
"data-url" => event.project.web_url, | "data-url" => event.project.web_url, |
"data-text" => "I just created a new project in GitLab! GitLab is version control on your server.", | "data-text" => "I just #{event.project.imported? ? "imported" : "created"} a new project in GitLab! GitLab is version control on your server.", |
"data-size" => "medium", | "data-size" => "medium", |
"data-related" => "gitlab", | "data-related" => "gitlab", |
"data-hashtags" => "gitlab", | "data-hashtags" => "gitlab", |
"data-count" => "none"} "data-count" => "none"}
Tweet Tweet
%script{src: "//platform.twitter.com/widgets.js"} %script{src: "//platform.twitter.com/widgets.js"}
\ No newline at end of file
...@@ -10,29 +10,16 @@ module Gitlab ...@@ -10,29 +10,16 @@ module Gitlab
end end
def execute def execute
@project = Project.new( ::Projects::CreateService.new(current_user,
name: repo["name"], name: repo["name"],
path: repo["slug"], path: repo["slug"],
description: repo["description"], description: repo["description"],
namespace: namespace, namespace_id: namespace.id,
creator: current_user,
visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC, visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
import_type: "bitbucket", import_type: "bitbucket",
import_source: "#{repo["owner"]}/#{repo["slug"]}", import_source: "#{repo["owner"]}/#{repo["slug"]}",
import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git" import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git"
) ).execute
if @project.save!
@project.reload
if @project.import_failed?
@project.import_retry
else
@project.import_start
end
end
@project
end end
end end
end end
......
...@@ -10,29 +10,16 @@ module Gitlab ...@@ -10,29 +10,16 @@ module Gitlab
end end
def execute def execute
@project = Project.new( ::Projects::CreateService.new(current_user,
name: repo.name, name: repo.name,
path: repo.name, path: repo.name,
description: repo.description, description: repo.description,
namespace: namespace, namespace_id: namespace.id,
creator: current_user,
visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC, visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
import_type: "github", import_type: "github",
import_source: repo.full_name, import_source: repo.full_name,
import_url: repo.clone_url.sub("https://", "https://#{current_user.github_access_token}@") import_url: repo.clone_url.sub("https://", "https://#{current_user.github_access_token}@")
) ).execute
if @project.save!
@project.reload
if @project.import_failed?
@project.import_retry
else
@project.import_start
end
end
@project
end end
end end
end end
......
...@@ -10,29 +10,16 @@ module Gitlab ...@@ -10,29 +10,16 @@ module Gitlab
end end
def execute def execute
@project = Project.new( ::Projects::CreateService.new(current_user,
name: repo["name"], name: repo["name"],
path: repo["path"], path: repo["path"],
description: repo["description"], description: repo["description"],
namespace: namespace, namespace_id: namespace.id,
creator: current_user,
visibility_level: repo["visibility_level"], visibility_level: repo["visibility_level"],
import_type: "gitlab", import_type: "gitlab",
import_source: repo["path_with_namespace"], import_source: repo["path_with_namespace"],
import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{current_user.gitlab_access_token}@") import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{current_user.gitlab_access_token}@")
) ).execute
if @project.save!
@project.reload
if @project.import_failed?
@project.import_retry
else
@project.import_start
end
end
@project
end end
end end
end end
......
...@@ -10,29 +10,16 @@ module Gitlab ...@@ -10,29 +10,16 @@ module Gitlab
end end
def execute def execute
@project = Project.new( ::Projects::CreateService.new(current_user,
name: repo.name, name: repo.name,
path: repo.path, path: repo.path,
description: repo.description, description: repo.description,
namespace: namespace, namespace_id: namespace.id,
creator: current_user,
visibility_level: Gitlab::VisibilityLevel::PUBLIC, visibility_level: Gitlab::VisibilityLevel::PUBLIC,
import_type: "gitorious", import_type: "gitorious",
import_source: repo.full_name, import_source: repo.full_name,
import_url: repo.import_url import_url: repo.import_url
) ).execute
if @project.save!
@project.reload
if @project.import_failed?
@project.import_retry
else
@project.import_start
end
end
@project
end end
end end
end end
......
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