From 4ba4275632351518a4b65e432914a60747ce3e52 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 23 May 2018 17:39:52 +0200 Subject: Bump version to 7.1.3 --- CHANGELOG | 3 +++ lib/gitlab_shell.rb | 8 +++++++- spec/gitlab_shell_spec.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 388c478..af2bcb5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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', -- cgit v1.2.1