Created
          November 7, 2012 18:48 
        
      - 
      
- 
        Save erochest/4033576 to your computer and use it in GitHub Desktop. 
    abusing blocks
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def update_subm(name, &block) | |
| puts "Updating submodules for '#{name}'...." | |
| if block.nil? | |
| sh %{cd #{name} ; #{GIT_SM_UP}} | |
| else | |
| sh %{cd #{name} ; #{GIT_SM_UP}} do |o, r| | |
| block.call(o, r) | |
| end | |
| end | |
| end | |
| desc 'This does a recursive git submodule update.' | |
| task :update do | |
| update_subm '.' do |ok, res| | |
| puts "ERROR: #{ok}. #{res}. Continuing." | |
| end | |
| sh %{cd #{GEOEXPLORER_DIR}/app/static/externals/gxp/externals/TimeManager ; git reset --hard HEAD} | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Basically, I'm trying to eat the error that the first shell state in the task throws. To do that, I want to define a block on the calling location, but just pass it untouched to the call to
sh.Originally, I'd been calling
update_submmultiple times, so having it refactored into its own method made more sense.I assume that what I'm doing here can't be right.