summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-09-13 16:12:39 +0000
committerRobert Speicher <robert@gitlab.com>2016-09-13 16:12:39 +0000
commitd25633f8b0eb22fbe6cdb7fe848d3eb90414c187 (patch)
tree09f9dfcba31613fb6cea14b15f5aac1fb75842ec /lib
parent404f438f45c2da884cf4f16239ac1fda548db09f (diff)
parent05b52e0f5e4d06edb736849daaac5c33c68c1d47 (diff)
downloadgitlab-ce-d25633f8b0eb22fbe6cdb7fe848d3eb90414c187.tar.gz
Merge branch '20780-import-github-release-notes' into 'master'
Import GitHub release notes ## Why was this MR needed? Release notes aren't currently migrated over when importing from GitHub ## What are the relevant issue numbers? #20780 See merge request !5981
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/github_import/importer.rb13
-rw-r--r--lib/gitlab/github_import/release_formatter.rb23
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index 0388c58f811..d35ee2a1c65 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -24,6 +24,7 @@ module Gitlab
import_issues
import_pull_requests
import_wiki
+ import_releases
handle_errors
true
@@ -177,6 +178,18 @@ module Gitlab
errors << { type: :wiki, errors: e.message }
end
end
+
+ def import_releases
+ releases = client.releases(repo, per_page: 100)
+ releases.each do |raw|
+ begin
+ gh_release = ReleaseFormatter.new(project, raw)
+ gh_release.create! if gh_release.valid?
+ rescue => e
+ errors << { type: :release, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message }
+ end
+ end
+ end
end
end
end
diff --git a/lib/gitlab/github_import/release_formatter.rb b/lib/gitlab/github_import/release_formatter.rb
new file mode 100644
index 00000000000..73d643b00ad
--- /dev/null
+++ b/lib/gitlab/github_import/release_formatter.rb
@@ -0,0 +1,23 @@
+module Gitlab
+ module GithubImport
+ class ReleaseFormatter < BaseFormatter
+ def attributes
+ {
+ project: project,
+ tag: raw_data.tag_name,
+ description: raw_data.body,
+ created_at: raw_data.created_at,
+ updated_at: raw_data.created_at
+ }
+ end
+
+ def klass
+ Release
+ end
+
+ def valid?
+ !raw_data.draft
+ end
+ end
+ end
+end