99ddd1dcbe
The reason is that Gitea plan to be GitHub-compatible so it makes sense to just modify GitHubImport a bit for now, and hopefully we can change it to GitHubishImport once Gitea is 100%-compatible. Signed-off-by: Rémy Coutable <remy@rymai.me>
36 lines
890 B
Ruby
36 lines
890 B
Ruby
module Gitlab
|
|
module GithubImport
|
|
class BaseFormatter
|
|
attr_reader :formatter, :project, :raw_data
|
|
|
|
def initialize(project, raw_data)
|
|
@project = project
|
|
@raw_data = raw_data
|
|
@formatter = Gitlab::ImportFormatter.new
|
|
end
|
|
|
|
def create!
|
|
project.public_send(project_association).find_or_create_by!(find_condition) do |record|
|
|
record.attributes = attributes
|
|
end
|
|
end
|
|
|
|
def url
|
|
raw_data.url || ''
|
|
end
|
|
|
|
private
|
|
|
|
def gitlab_user_id(github_id)
|
|
User.joins(:identities).
|
|
find_by("identities.extern_uid = ? AND identities.provider = 'github'", github_id.to_s).
|
|
try(:id)
|
|
end
|
|
|
|
def gitlab_author_id
|
|
return @gitlab_author_id if defined?(@gitlab_author_id)
|
|
@gitlab_author_id = gitlab_user_id(raw_data.user.id)
|
|
end
|
|
end
|
|
end
|
|
end
|