summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-05-23 17:39:52 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-05-24 12:21:15 +0200
commit4ba4275632351518a4b65e432914a60747ce3e52 (patch)
tree80f88831eb64c8b4c4439d8759afb53c30df3929
parentaa10b70f2a37c45bc2551f2a0d34a835dc7189f9 (diff)
downloadgitlab-shell-bvl-display-username-instead-of-fullname.tar.gz
-rw-r--r--CHANGELOG3
-rw-r--r--lib/gitlab_shell.rb8
-rw-r--r--spec/gitlab_shell_spec.rb2
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',