2019-02-13 22:33:31 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class User
|
|
|
|
attr_reader :username, :name, :email, :gl_id
|
|
|
|
|
|
|
|
def self.from_gitlab(gitlab_user)
|
2018-12-05 23:21:45 +05:30
|
|
|
new(gitlab_user.username, gitlab_user.name, gitlab_user.commit_email, Gitlab::GlId.gl_id(gitlab_user))
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|