Module: Theoj::Git

Included in:
Paper, PublishedPaper
Defined in:
lib/theoj/git.rb

Instance Method Summary collapse

Instance Method Details

#change_branch(branch, local_path) ⇒ Object



15
16
17
18
19
# File 'lib/theoj/git.rb', line 15

def change_branch(branch, local_path)
  return true if (branch.nil? || branch.strip.empty?)
  stdout, stderr, status = Open3.capture3 "git -C #{local_path} switch #{branch}"
  status.success?
end

#clone_repo(url, local_path) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/theoj/git.rb', line 6

def clone_repo(url, local_path)
  url = URI.extract(url.to_s).first
  return false if url.nil?

  FileUtils.mkdir_p(local_path)
  stdout, stderr, status = Open3.capture3 "git clone #{url} #{local_path}"
  status.success?
end