Class: ProcfileSplit::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/procfile_split/git.rb

Class Method Summary collapse

Class Method Details

.add_and_commit(filename, message) ⇒ Object



24
25
26
27
28
29
# File 'lib/procfile_split/git.rb', line 24

def self.add_and_commit(filename, message)
  system "git add '#{filename}'; git commit -m '#{message}'"
  if $? != 0
    raise "abort: git commit failed"
  end
end

.checkout(branch) ⇒ Object



17
18
19
20
21
22
# File 'lib/procfile_split/git.rb', line 17

def self.checkout(branch)
  system "git checkout -b \"#{branch}\""
  if $? != 0
    raise "abort: git checkout failed"
  end
end

.checkout_masterObject



31
32
33
# File 'lib/procfile_split/git.rb', line 31

def self.checkout_master
  system "git checkout master"
end

.list_branchObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/procfile_split/git.rb', line 5

def self.list_branch
  Open3.popen3("git branch") do |stdin, stdout, stderr, wait_thr|
    exit_status = wait_thr.value

    if exit_status == 0
      stdout.read.split("\n").collect(){|branch| branch.gsub(/\\*\W/, "") }
    else
      raise stderr.read
    end
  end
end