2017-08-22 07:05:36 -04:00
|
|
|
module Gitlab
|
|
|
|
module Git
|
2017-09-13 12:16:56 -04:00
|
|
|
class User
|
2017-08-02 14:14:50 -04:00
|
|
|
attr_reader :username, :name, :email, :gl_id
|
2017-08-22 10:27:15 -04:00
|
|
|
|
2017-09-13 12:16:56 -04:00
|
|
|
def self.from_gitlab(gitlab_user)
|
2017-08-02 14:14:50 -04:00
|
|
|
new(gitlab_user.username, gitlab_user.name, gitlab_user.email, Gitlab::GlId.gl_id(gitlab_user))
|
2017-09-13 12:16:56 -04:00
|
|
|
end
|
|
|
|
|
2017-10-03 12:53:11 -04:00
|
|
|
def self.from_gitaly(gitaly_user)
|
2017-10-23 16:31:05 -04:00
|
|
|
new(gitaly_user.gl_username, gitaly_user.name, gitaly_user.email, gitaly_user.gl_id)
|
2017-10-03 12:53:11 -04:00
|
|
|
end
|
|
|
|
|
2017-08-02 14:14:50 -04:00
|
|
|
def initialize(username, name, email, gl_id)
|
|
|
|
@username = username
|
2017-08-22 07:05:36 -04:00
|
|
|
@name = name
|
|
|
|
@email = email
|
|
|
|
@gl_id = gl_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def ==(other)
|
2017-08-02 14:14:50 -04:00
|
|
|
[username, name, email, gl_id] == [other.username, other.name, other.email, other.gl_id]
|
2017-08-22 07:05:36 -04:00
|
|
|
end
|
2017-10-23 16:31:05 -04:00
|
|
|
|
|
|
|
def to_gitaly
|
|
|
|
Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name, email: email)
|
|
|
|
end
|
2017-08-22 07:05:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|