lib/r10k/git/stateful_repository.rb
# Returns true if the sync actually updated the repo, false otherwise
Returns true if the sync actually updated the repo, false otherwise
Returns true if the sync actually updated the repo false otherwise
def sync(ref, force=true)
    @cache.sync if sync_cache?(ref)
    sha = @cache.resolve(ref)
    if sha.nil?
      raise R10K::Git::UnresolvableRefError.new(_("Unable to sync repo to unresolvable ref '%{ref}'") % {ref: ref}, :git_dir => @repo.git_dir)
    end
    workdir_status = status(ref)
    updated = true
    case workdir_status
    when :absent
      logger.debug(_("Cloning %{repo_path} and checking out %{ref}") % {repo_path: @repo.path, ref: ref })
      @repo.clone(@remote, {:ref => sha})
    when :mismatched
      logger.debug(_("Replacing %{repo_path} and checking out %{ref}") % {repo_path: @repo.path, ref: ref })
      @repo.path.rmtree
      @repo.clone(@remote, {:ref => sha})
    when :outdated
      logger.debug(_("Updating %{repo_path} to %{ref}") % {repo_path: @repo.path, ref: ref })
      @repo.checkout(sha, {:force => force})
    when :dirty
      if force
        logger.warn(_("Overwriting local modifications to %{repo_path}") % {repo_path: @repo.path})
        logger.debug(_("Updating %{repo_path} to %{ref}") % {repo_path: @repo.path, ref: ref })
        @repo.checkout(sha, {:force => force})
      else
        logger.warn(_("Skipping %{repo_path} due to local modifications") % {repo_path: @repo.path})
        updated = false
      end
    else
      logger.debug(_("%{repo_path} is already at Git ref %{ref}") % {repo_path: @repo.path, ref: ref })
      updated = false
    end
    updated
  end
def sync ( ref , force = true ) @cache . sync if sync_cache? ( ref ) sha = @cache . resolve ( ref ) if sha . nil? raise R10K :: Git :: UnresolvableRefError . new ( _ ( "Unable to sync repo to unresolvable ref '%{ref}'" ) % { ref : ref } , :git_dir => @repo . git_dir ) end workdir_status = status ( ref ) updated = true case workdir_status when :absent logger . debug ( _ ( "Cloning %{repo_path} and checking out %{ref}" ) % { repo_path : @repo . path , ref : ref } ) @repo . clone ( @remote , { :ref => sha } ) when :mismatched logger . debug ( _ ( "Replacing %{repo_path} and checking out %{ref}" ) % { repo_path : @repo . path , ref : ref } ) @repo . path . rmtree @repo . clone ( @remote , { :ref => sha } ) when :outdated logger . debug ( _ ( "Updating %{repo_path} to %{ref}" ) % { repo_path : @repo . path , ref : ref } ) @repo . checkout ( sha , { :force => force } ) when :dirty if force logger . warn ( _ ( "Overwriting local modifications to %{repo_path}" ) % { repo_path : @repo . path } ) logger . debug ( _ ( "Updating %{repo_path} to %{ref}" ) % { repo_path : @repo . path , ref : ref } ) @repo . checkout ( sha , { :force => force } ) else logger . warn ( _ ( "Skipping %{repo_path} due to local modifications" ) % { repo_path : @repo . path } ) updated = false end else logger . debug ( _ ( "%{repo_path} is already at Git ref %{ref}" ) % { repo_path : @repo . path , ref : ref } ) updated = false end updated end
Returns true if the sync actually updated the repo, false otherwise
Returns true if the sync actually updated the repo false otherwise
ref
force