Class: Gitlab::GithubImport::Importer::ReleasesImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Importer::ReleasesImporter
show all
- Includes:
- BulkImporting
- Defined in:
- lib/gitlab/github_import/importer/releases_importer.rb
Instance Attribute Summary
#client, #project
Instance Method Summary
collapse
#build_database_rows, #bulk_insert, #bulk_insert_failures, #initialize
Instance Method Details
#already_imported?(release) ⇒ Boolean
29
30
31
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 29
def already_imported?(release)
existing_tags.include?(release[:tag_name]) || release[:tag_name].nil?
end
|
#build_attributes(release) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 33
def build_attributes(release)
existing_tags.add(release[:tag_name])
{
name: release[:name],
tag: release[:tag_name],
author_id: fetch_author_id(release),
description: description_for(release),
created_at: release[:created_at],
updated_at: release[:created_at],
released_at: release[:published_at] || Time.current,
project_id: project.id
}
end
|
#build_releases ⇒ Object
25
26
27
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 25
def build_releases
build_database_rows(each_release)
end
|
#description_for(release) ⇒ Object
53
54
55
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 53
def description_for(release)
release[:body].presence || "Release for tag #{release[:tag_name]}"
end
|
#each_release ⇒ Object
49
50
51
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 49
def each_release
client.releases(project.import_source)
end
|
#execute ⇒ Object
Note: if you’re going to replace ‘legacy_bulk_insert` with something that triggers callback to generate HTML version - you also need to regenerate it in Gitlab::GithubImport::Importer::NoteAttachmentsImporter.
18
19
20
21
22
23
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 18
def execute
rows, validation_errors = build_releases
bulk_insert(rows)
bulk_insert_failures(validation_errors) if validation_errors.any?
end
|
rubocop: disable CodeReuse/ActiveRecord
10
11
12
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 10
def existing_tags
@existing_tags ||= project.releases.pluck(:tag).to_set
end
|
#object_type ⇒ Object
57
58
59
|
# File 'lib/gitlab/github_import/importer/releases_importer.rb', line 57
def object_type
:release
end
|