gitlab-org--gitlab-foss/lib/gitlab/git/user.rb
gfyoung ebf98f27c4 Enable even more frozen string in lib/gitlab
Enables frozen string for the following:

* lib/gitlab/fogbugz_import/**/*.rb
* lib/gitlab/gfm/**/*.rb
* lib/gitlab/git/**/*.rb
* lib/gitlab/gitaly_client/**/*.rb
* lib/gitlab/gitlab_import/**/*.rb
* lib/gitlab/google_code_import/**/*.rb
* lib/gitlab/gpg/**/*.rb
* lib/gitlab/grape_logging/**/*.rb
* lib/gitlab/graphql/**/*.rb
* lib/gitlab/graphs/**/*.rb
* lib/gitlab/hashed_storage/**/*.rb
* lib/gitlab/health_checks/**/*.rb

Partially address gitlab-org/gitlab-ce#47424.
2018-11-13 11:42:15 -08:00

37 lines
971 B
Ruby

# frozen_string_literal: true
module Gitlab
module Git
class User
attr_reader :username, :name, :email, :gl_id
def self.from_gitlab(gitlab_user)
new(gitlab_user.username, gitlab_user.name, gitlab_user.commit_email, Gitlab::GlId.gl_id(gitlab_user))
end
def self.from_gitaly(gitaly_user)
new(
gitaly_user.gl_username,
Gitlab::EncodingHelper.encode!(gitaly_user.name),
Gitlab::EncodingHelper.encode!(gitaly_user.email),
gitaly_user.gl_id
)
end
def initialize(username, name, email, gl_id)
@username = username
@name = name
@email = email
@gl_id = gl_id
end
def ==(other)
[username, name, email, gl_id] == [other.username, other.name, other.email, other.gl_id]
end
def to_gitaly
Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name.b, email: email.b)
end
end
end
end