Sha256: 5a46086f4bc37aeb0670246082e925c24c4b827eaa399724210d188aff734996

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 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
      single_branch = @context.has_key?("single_branch") ? @context["single_branch"] : true
      depth = @context.has_key?("depth") ? @context["depth"] : 1
      GitUtil.get(@context['repo'], self['target_path'], @context.version_type, @context.version, single_branch, depth)
    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

10 entries across 10 versions & 1 rubygems

Version Path
docman-0.0.107 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.106 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.105 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.104 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.103 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.102 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.101 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.100 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.99 lib/docman/commands/git_repo_provider_cmd.rb
docman-0.0.98 lib/docman/commands/git_repo_provider_cmd.rb