diff options
author | Valery Sizov <valery@gitlab.com> | 2015-02-02 17:01:07 -0800 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-02-05 12:50:34 -0800 |
commit | 33349dd54928a0b074b4ae3ebfabf214799fc085 (patch) | |
tree | 593a14d0f6df812410349f353e252e3a58d8cacd /lib/gitlab/gitlab_import | |
parent | 713bc152bde5396bb95a1555907bcd9a2847839d (diff) | |
download | gitlab-ce-33349dd54928a0b074b4ae3ebfabf214799fc085.tar.gz |
GitLab.com integration: refactoring
Diffstat (limited to 'lib/gitlab/gitlab_import')
-rw-r--r-- | lib/gitlab/gitlab_import/client.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/gitlab_import/importer.rb | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/gitlab/gitlab_import/client.rb b/lib/gitlab/gitlab_import/client.rb index 64e369e9c12..2206b68da99 100644 --- a/lib/gitlab/gitlab_import/client.rb +++ b/lib/gitlab/gitlab_import/client.rb @@ -13,7 +13,7 @@ module Gitlab ) if access_token - @api = OAuth2::AccessToken.from_hash(@client, :access_token => access_token) + @api = OAuth2::AccessToken.from_hash(@client, access_token: access_token) end end @@ -67,7 +67,7 @@ module Gitlab end def config - Gitlab.config.omniauth.providers.select{|provider| provider.name == "gitlab"}.first + Gitlab.config.omniauth.providers.find{|provider| provider.name == "gitlab"} end def github_options diff --git a/lib/gitlab/gitlab_import/importer.rb b/lib/gitlab/gitlab_import/importer.rb index 3e9087a556c..a529483c1e2 100644 --- a/lib/gitlab/gitlab_import/importer.rb +++ b/lib/gitlab/gitlab_import/importer.rb @@ -6,6 +6,7 @@ module Gitlab def initialize(project) @project = project @client = Client.new(project.creator.gitlab_access_token) + @formatter = Gitlab::ImportFormatter.new end def execute @@ -15,15 +16,16 @@ module Gitlab issues = client.issues(project_identifier) issues.each do |issue| - body = "*Created by: #{issue["author"]["name"]}*\n\n#{issue["description"]}" - + body = @formatter.author_line(issue["author"]["name"], issue["description"]) comments = client.issue_comments(project_identifier, issue["id"]) + if comments.any? - body += "\n\n\n**Imported comments:**\n" + body += @formatter.comments_header end + comments.each do |comment| - body += "\n\n*By #{comment["author"]["name"]} on #{comment["created_at"]}*\n\n#{comment["body"]}" + body += @formatter.comment_to_md(comment["author"]["name"], comment["created_at"], comment["body"]) end project.issues.create!( |