Class: GithubFlowCli::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/github_flow_cli/local.rb

Class Method Summary collapse

Class Method Details

.gitObject



20
21
22
# File 'lib/github_flow_cli/local.rb', line 20

def git
  @git ||= Git.open(File.expand_path('.'))
end

.repoObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/github_flow_cli/local.rb', line 6

def repo
  return @repo if @repo
  url = git.remote.url
  match = url&.match(%r{.*[:/](?<owner>.*?)/(?<name>.*?)\.git$})
  return nil unless match[:owner] && match[:name]
  @repo = Octokit::Repository.from_url("/#{match[:owner]}/#{match[:name]}")
rescue ArgumentError => ex
  if ex.message =~ /path does not exist/
    nil
  else
    raise
  end
end