Module: Git

Defined in:
lib/git.rb

Overview

this class interfaces with the local ‘git` command

Class Method Summary collapse

Class Method Details

.checkout_branch(text) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/git.rb', line 18

def checkout_branch(text)
  branch = text.downcase.gsub(/[^a-zA-Z0-9#]+/, '_')
  output = `git checkout -b #{branch} 2>&1`

  if output.match?(/A branch named '#{branch}' already exists/)
    `git checkout #{branch}`
  end
end

.remoteObject



6
7
8
# File 'lib/git.rb', line 6

def remote
  `git config --list | grep remote.origin.url`&.strip&.split(':')&.last
end

.repositoryObject



10
11
12
# File 'lib/git.rb', line 10

def repository
  remote.split('/').last.chomp('.git')
end

.repository_ownerObject



14
15
16
# File 'lib/git.rb', line 14

def repository_owner
  remote.split('/').first
end