Class: SpaceArchitect::GitClient

Inherits:
Object
  • Object
show all
Defined in:
lib/space_architect/git_client.rb

Instance Method Summary collapse

Instance Method Details

#commit_all(path, message) ⇒ Object

Best-effort: a missing git identity (user.name/user.email) must not abort space creation. Returns false on failure, leaving the repo initialized but uncommitted.



24
25
26
27
28
29
30
31
# File 'lib/space_architect/git_client.rb', line 24

def commit_all(path, message)
  path = Pathname.new(path)
  _, _, add_status = capture("git", "-C", path.to_s, "add", "-A")
  return false unless add_status.success?

  _, _, commit_status = capture("git", "-C", path.to_s, "commit", "-m", message)
  commit_status.success?
end

#init(path) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
# File 'lib/space_architect/git_client.rb', line 10

def init(path)
  path = Pathname.new(path)
  stdout, stderr, status = capture("git", "-C", path.to_s, "init")
  return true if status.success?

  output = [stdout, stderr].reject(&:empty?).join("\n").strip
  message = "git init failed for #{path}"
  message = "#{message}: #{output}" unless output.empty?
  raise GitError, message
end