diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-05-23 17:39:52 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-05-24 12:21:15 +0200 |
commit | 4ba4275632351518a4b65e432914a60747ce3e52 (patch) | |
tree | 80f88831eb64c8b4c4439d8759afb53c30df3929 | |
parent | aa10b70f2a37c45bc2551f2a0d34a835dc7189f9 (diff) | |
download | gitlab-shell-bvl-display-username-instead-of-fullname.tar.gz |
Bump version to 7.1.3bvl-display-username-instead-of-fullname
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | lib/gitlab_shell.rb | 8 | ||||
-rw-r--r-- | spec/gitlab_shell_spec.rb | 2 |
3 files changed, 11 insertions, 2 deletions
@@ -1,3 +1,6 @@ +v7.1.3 + - Use username instead of full name for identifying users (!204) + v7.1.2 - Add missing GitlabLogger#error method (!200) diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 0221624..9644cf4 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -196,8 +196,14 @@ class GitlabShell # rubocop:disable Metrics/ClassLength end end + def username_from_discover + return nil unless user && user['username'] + + "@#{user['username']}" + end + def username - @username ||= user && user['username'] || 'Anonymous' + @username ||= username_from_discover || 'Anonymous' end # User identifier to be used in log messages. diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index 0e8999b..eef0caf 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -31,7 +31,7 @@ describe GitlabShell do let(:api) do double(GitlabNet).tap do |api| - api.stub(discover: { 'name' => 'John Doe' }) + api.stub(discover: { 'name' => 'John Doe', 'username' => 'testuser' }) api.stub(check_access: GitAccessStatus.new( true, 'ok', |