Sha256: da49aa84d83cff36605a1eb197b26a4962787796e77ab5d7e6425cb22bf332d4

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

module Docman
  class GitRepoProvider < Docman::Command

    attr_reader :version

    register_command :git_repo_provider

    def validate_command
      raise "Please provide 'context'" if @context.nil?
      raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
    end

    def execute
      @execute_result = get_content
      # No commit hash for 'root' as it will be changed later
      @version = @context['type'] == 'root' ? @context['build_path'] : @execute_result
    end

    def changed?
      stored_version = @context.stored_version['result']
      @last_version = GitUtil.last_revision(self['target_path'])
      # TODO: diff with remote instead of get
      v = version(true)
      stored_version != v
    end

    def get_content
      GitUtil.get(@context['repo'], self['target_path'], @context.version_type, @context.version, true, 1)
    end

    def changed_from_last_version?
      @last_version != @version
    end

    def version(remote = false)
      # branch = remote ? "origin/#{@context.version}" : nil
      # @context['type'] == 'root' ? @context['build_path'] : GitUtil.last_revision(self['target_path'], branch)
      @context['type'] == 'root' ? @context['build_path'] : get_content
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
docman-0.0.97 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.96 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.95 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.94 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.93 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.92 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.91 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.90 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.89 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.88 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.87 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.86 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.85 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.84 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.83 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.82 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.81 lib/docman/commands/git_repo_provider_cmd.rb