Class: Gitlab::LegacyGithubImport::UserFormatter
- Inherits:
-
Object
- Object
- Gitlab::LegacyGithubImport::UserFormatter
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/legacy_github_import/user_formatter.rb
Constant Summary collapse
- GITEA_GHOST_EMAIL =
'ghost_user@gitea_import_dummy_email.com'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#source_user_mapper ⇒ Object
readonly
Returns the value of attribute source_user_mapper.
Instance Method Summary collapse
- #gitlab_id ⇒ Object
- #id ⇒ Object
-
#initialize(client, raw, project, source_user_mapper) ⇒ UserFormatter
constructor
A new instance of UserFormatter.
- #login ⇒ Object
- #source_user ⇒ Object
Constructor Details
#initialize(client, raw, project, source_user_mapper) ⇒ UserFormatter
Returns a new instance of UserFormatter.
12 13 14 15 16 17 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 12 def initialize(client, raw, project, source_user_mapper) @client = client @raw = raw @project = project @source_user_mapper = source_user_mapper end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 8 def client @client end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 8 def project @project end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 8 def raw @raw end |
#source_user_mapper ⇒ Object (readonly)
Returns the value of attribute source_user_mapper.
8 9 10 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 8 def source_user_mapper @source_user_mapper end |
Instance Method Details
#gitlab_id ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 27 def gitlab_id return find_by_email unless user_mapping_enabled? return GithubImport.ghost_user_id(project.organization_id) if ghost_user? return project.root_ancestor.owner_id if map_to_personal_namespace_owner? gitlab_user&.id end |
#id ⇒ Object
19 20 21 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 19 def id raw[:id] end |
#login ⇒ Object
23 24 25 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 23 def login raw[:login] end |
#source_user ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/gitlab/legacy_github_import/user_formatter.rb', line 36 def source_user return if !user_mapping_enabled? || map_to_personal_namespace_owner? || ghost_user? source_user_mapper.find_or_create_source_user( source_name: gitea_user[:full_name].presence || gitea_user[:login], source_username: gitea_user[:login], source_user_identifier: raw[:id] ) end |