Module: GitFit::GhHelpers

Included in:
GhConfigCLI, GhSecretCLI
Defined in:
lib/git_fit/cli/gh_cli.rb

Instance Method Summary collapse

Instance Method Details

#detect_repo(url = nil) ⇒ Object



8
9
10
11
# File 'lib/git_fit/cli/gh_cli.rb', line 8

def detect_repo(url = nil)
  url ||= `git remote get-url origin`.chomp
  url.sub(%r{.*github\.com[:/]}, '').sub(/\.git$/, '')
end

#gh(*args) ⇒ Object



13
14
15
16
17
18
# File 'lib/git_fit/cli/gh_cli.rb', line 13

def gh(*args)
  repo = options[:repo] || detect_repo
  out, err, st = Open3.capture3('gh', *args.map(&:to_s), '-R', repo)
  raise "gh: #{err.strip}" unless st.success?
  out
end