Skip to content

Commit

Permalink
Created Git class to wrap calls to git and checking for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mowat27 committed Sep 21, 2011
1 parent 02f8d73 commit 02262ee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions retreat_gem/lib/coderetreat/retreat.rb
Expand Up @@ -63,6 +63,13 @@ def self.clone(source_repo, local_repo)
%x{git clone #{source_repo} #{local_repo}} %x{git clone #{source_repo} #{local_repo}}
raise EnvError.new("Could not clone #{source_repo}") unless $? == 0 raise EnvError.new("Could not clone #{source_repo}") unless $? == 0
end end

def self.pull(local_repo)
local_repo.flip_into_and_run do
%x{git pull origin master}
raise EnvError.new("Could not pull origin master into #{local_repo}") unless $? == 0
end
end
end end


module Actions module Actions
Expand Down Expand Up @@ -107,8 +114,7 @@ def self.run!
def run! def run!
validate_environment! validate_environment!
puts "Pulling coderetreat repo into #{@local_repo}..." puts "Pulling coderetreat repo into #{@local_repo}..."
%x{git clone #{@source_repo} #{@local_repo}} Git.clone @source_repo, @local_repo
raise EnvError.new("Installation failed - could not clone github repo") unless $? == 0
puts "\nInstallation completed! Here is some information..." puts "\nInstallation completed! Here is some information..."
Info.run! Info.run!
puts "\nRun 'retreat start <language> [location]' to start a new iteration" puts "\nRun 'retreat start <language> [location]' to start a new iteration"
Expand All @@ -129,7 +135,7 @@ def self.run!
def run! def run!
validate_environment! validate_environment!
puts "Updating sources at #{@local_repo}" puts "Updating sources at #{@local_repo}"
@local_repo.flip_into_and_run { %x!git pull origin master! } Git.pull @local_repo
end end


def validate_environment! def validate_environment!
Expand All @@ -154,7 +160,7 @@ def message
result =<<EOS result =<<EOS
Source Repo: #{@source_repo} Source Repo: #{@source_repo}
Local Repo: #{@local_repo} Local Repo: #{@local_repo}
Languages Available: #{languages.join(",")} Languages Available: #{languages.join(", ")}
EOS EOS


result result
Expand Down

0 comments on commit 02262ee

Please sign in to comment.