Skip to content
Browse files

Fixed problem where update puls local repo changes from itself

  • Loading branch information...
1 parent 4202b72 commit 02f8d7304731af3272da2f666c56f2e7efb7fc20 @mowat27 mowat27 committed
Showing with 21 additions and 3 deletions.
  1. +20 −2 retreat_gem/lib/coderetreat/retreat.rb
  2. +1 −1 retreat_gem/retreat.gemspec
View
22 retreat_gem/lib/coderetreat/retreat.rb
@@ -46,13 +46,30 @@ def copy_to(target)
def ls
Dir["#{@path}/*"].map{|listing_item| Path.new(listing_item)}
end
+
+ def flip_into_and_run
+ starting_dir = Dir.getwd
+ begin
+ Dir.chdir @path
+ yield
+ ensure
+ Dir.chdir starting_dir
+ end
+ end
+ end
+
+ class Git
+ def self.clone(source_repo, local_repo)
+ %x{git clone #{source_repo} #{local_repo}}
+ raise EnvError.new("Could not clone #{source_repo}") unless $? == 0
+ end
end
module Actions
class Action
def initialize
@home = Path.new(Etc.getpwuid.dir, '.retreat')
- @local_repo = Path.new(Etc.getpwuid.dir, '.retreat', 'retreat')
+ @local_repo = Path.new(Etc.getpwuid.dir, '.retreat', 'coderetreat')
@source_repo = "https://github.com/coreyhaines/coderetreat.git"
@starting_points = @local_repo.join("starting_points")
end
@@ -91,6 +108,7 @@ def run!
validate_environment!
puts "Pulling coderetreat repo into #{@local_repo}..."
%x{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..."
Info.run!
puts "\nRun 'retreat start <language> [location]' to start a new iteration"
@@ -111,7 +129,7 @@ def self.run!
def run!
validate_environment!
puts "Updating sources at #{@local_repo}"
- %x{git pull #{@local_repo}}
+ @local_repo.flip_into_and_run { %x!git pull origin master! }
end
def validate_environment!
View
2 retreat_gem/retreat.gemspec
@@ -2,7 +2,7 @@ require 'rubygems'
SPEC = Gem::Specification.new do |s|
s.name = "retreat"
- s.version = '0.1.0'
+ s.version = '0.1.1'
s.author = "Adrian Mowat"
s.homepage = "https://github.com/coreyhaines/coderetreat"
s.summary = "Command line utilities for coderetreat"

0 comments on commit 02f8d73

Please sign in to comment.
Something went wrong with that request. Please try again.