summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_access_status.rb14
-rw-r--r--lib/gitlab_net.rb8
-rw-r--r--lib/gitlab_shell.rb9
3 files changed, 21 insertions, 10 deletions
diff --git a/lib/gitlab_access_status.rb b/lib/gitlab_access_status.rb
index 988ff7a..69d914e 100644
--- a/lib/gitlab_access_status.rb
+++ b/lib/gitlab_access_status.rb
@@ -1,12 +1,13 @@
require 'json'
class GitAccessStatus
- attr_reader :message, :gl_repository, :repository_path, :gitaly, :geo_node
+ attr_reader :message, :gl_repository, :gl_username, :repository_path, :gitaly, :geo_node
- def initialize(status, message, gl_repository, repository_path, gitaly, geo_node = false)
+ def initialize(status, message, gl_repository:, gl_username:, repository_path:, gitaly:, geo_node:)
@status = status
@message = message
@gl_repository = gl_repository
+ @gl_username = gl_username
@repository_path = repository_path
@gitaly = gitaly
@geo_node = geo_node
@@ -16,10 +17,11 @@ class GitAccessStatus
values = JSON.parse(json)
self.new(values["status"],
values["message"],
- values["gl_repository"],
- values["repository_path"],
- values["gitaly"],
- values["geo_node"])
+ gl_repository: values["gl_repository"],
+ gl_username: values["gl_username"],
+ repository_path: values["repository_path"],
+ gitaly: values["gitaly"],
+ geo_node: values["geo_node"])
end
def allowed?
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index de0cc57..34f10c5 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -40,7 +40,13 @@ class GitlabNet
if resp.code == '200'
GitAccessStatus.create_from_json(resp.body)
else
- GitAccessStatus.new(false, 'API is not accessible', nil, nil, nil)
+ GitAccessStatus.new(false,
+ 'API is not accessible',
+ gl_repository: nil,
+ gl_username: nil,
+ repository_path: nil,
+ gitaly: nil,
+ geo_node: false)
end
end
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 243c629..e7e7f04 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -20,7 +20,7 @@ class GitlabShell
# to undo an already set parameter: https://www.spinics.net/lists/git/msg256772.html
GIT_CONFIG_SHOW_ALL_REFS = "transfer.hideRefs=!refs".freeze
- attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :show_all_refs
+ attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :show_all_refs, :username
attr_reader :repo_path
def initialize(key_id)
@@ -113,6 +113,7 @@ class GitlabShell
@gl_repository = status.gl_repository
@gitaly = status.gitaly
@show_all_refs = status.geo_node
+ @username = status.gl_username
end
def process_cmd(args)
@@ -139,7 +140,8 @@ class GitlabShell
gitaly_request = {
'repository' => @gitaly['repository'],
'gl_repository' => @gl_repository,
- 'gl_id' => @key_id
+ 'gl_id' => @key_id,
+ 'gl_username' => @username
}
gitaly_request['git_config_options'] = [GIT_CONFIG_SHOW_ALL_REFS] if @show_all_refs
@@ -168,7 +170,8 @@ class GitlabShell
'LANG' => ENV['LANG'],
'GL_ID' => @key_id,
'GL_PROTOCOL' => GL_PROTOCOL,
- 'GL_REPOSITORY' => @gl_repository
+ 'GL_REPOSITORY' => @gl_repository,
+ 'GL_USERNAME' => @username
}
if @gitaly && @gitaly.include?('token')
env['GITALY_TOKEN'] = @gitaly['token']