Module: Gl
- Defined in:
- lib/gl.rb,
lib/gl/cli.rb,
lib/gl/version.rb,
lib/gl/cli/global.rb,
lib/gl/cli/issues.rb,
lib/gl/cli/registry.rb,
lib/gl/cli/merge_requests.rb
Defined Under Namespace
Classes: CLI, Error, Global, Issues, MergeRequests, Registry
Constant Summary
collapse
- VERSION =
'0.4.1'
Class Method Summary
collapse
Class Method Details
.current_project(project = nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/gl.rb', line 16
def self.current_project(project = nil)
current_remote = project || Gl.remote_url
if current_remote.empty?
prompt = TTY::Prompt.new
prompt.ask('No remote found, please enter a project (like `group/project`)')
else
remote_parse[1]
end
end
|
.open_in_browser(url) ⇒ Object
27
28
29
30
|
# File 'lib/gl.rb', line 27
def self.open_in_browser(url)
url = "#{Gitlab.endpoint.gsub('api/v4', '')}#{url}"
`sensible-browser #{url} > /dev/null 2>&1`
end
|
.remote_base ⇒ Object
64
65
66
|
# File 'lib/gl.rb', line 64
def self.remote_base
remote_parse[0]
end
|
.remote_parse ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/gl.rb', line 43
def self.remote_parse
if remote_url.start_with?('git@')
regexp = %r{git@(.*?)(:|\/)(.*)?(\.git)}
url = remote_url
host = url.gsub(regexp, '\1')
project = url.gsub(regexp, '\3')
else
uri = URI(remote_url)
host = uri.host
project = uri.path.gsub(%r{\/(.*)\.git$}, '\1')
end
if host.nil? || project.nil?
puts 'Could not discover git remote. Make sure you are in a valid git repository'
exit(1)
end
[host, project]
end
|
.remote_slug ⇒ Object
68
69
70
|
# File 'lib/gl.rb', line 68
def self.remote_slug
remote_base.gsub('.', '-')
end
|
.remote_url ⇒ Object
39
40
41
|
# File 'lib/gl.rb', line 39
def self.remote_url
`git config --get remote.origin.url`.chomp
end
|
.validate_endpoint! ⇒ Object
32
33
34
35
36
37
|
# File 'lib/gl.rb', line 32
def self.validate_endpoint!
return if Net::HTTP.get(URI("#{Gitlab.endpoint}version")) == '{"message":"401 Unauthorized"}'
puts 'It seems this is not a valid GitLab repository'
exit(1)
end
|