lib/core/plugin/project.rb in nucleon-0.1.12 vs lib/core/plugin/project.rb in nucleon-0.1.13

- old
+ new

@@ -765,16 +765,15 @@ #----------------------------------------------------------------------------- # Remote operations def pull(remote = :edit, options = {}) + config = Config.ensure(options).import({ :remote => remote }) success = false if can_persist? - localize do - config = Config.ensure(options).import({ :remote => remote }) - + localize do if extension_check(:pull, { :directory => directory, :config => config }) remote = config.delete(:remote) if remote(remote) logger.info("Pulling from #{remote} into #{directory}") @@ -804,21 +803,33 @@ end #--- def push(remote = :edit, options = {}) + config = Config.ensure(options).import({ :remote => remote }) success = false + push_project = lambda do |push_remote| + logger.info("Pushing to #{push_remote} from #{directory}") + success = yield(config, push_remote) if block_given? && pull(push_remote, config) + end + if can_persist? - localize do - config = Config.ensure(options).import({ :remote => remote }) - + localize do if extension_check(:push, { :directory => directory, :config => config }) remote = config.delete(:remote) + tries = config.delete(:tries, 5) + # TODO: Figure out a better way through specialized exception handling if remote(remote) - logger.info("Pushing to #{remote} from #{directory}") - success = yield(config, remote) if block_given? && pull(remote, options) + begin + success = push_project.call(remote) + raise unless success + + rescue + tries -= 1 + retry if tries > 0 + end end if success config.delete(:revision)