22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/gl/cli.rb', line 22
def self.setup
Gitlab.endpoint = "https://#{Gl.remote_base}/api/v4/"
Gl.validate_endpoint!
token = `git config --get gl.#{Gl.remote_slug}.token`.chomp
if token.empty?
prompt = TTY::Prompt.new
Gl.open_in_browser('profile/personal_access_tokens')
token = prompt.mask("Please enter your GitLab token for #{Gl.remote_base}")
token_name = "gl.#{Gl.remote_slug}.token"
if prompt.yes?("Do you want to persist the token as #{token_name} to your git config")
`git config --global --add #{token_name} #{token}`
end
end
Gitlab.private_token = token
end
|