Class: Docman::GitRepoProvider

Inherits:
Command
  • Object
show all
Defined in:
lib/docman/commands/git_repo_provider_cmd.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#type

Instance Method Summary collapse

Methods inherited from Command

#add_action, #add_actions, #config, create, #describe, #initialize, #perform, #prefix, register_command, #replace_placeholder, #run_actions, #run_with_hooks

Methods included from Logging

#log, logger, #logger, #prefix, #properties_info, #with_logging

Constructor Details

This class inherits a constructor from Docman::Command

Instance Attribute Details

#version(remote = false) ⇒ Object (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 4

def version
  @version
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 19

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

#changed_from_last_version?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 31

def changed_from_last_version?
  @last_version != @version
end

#executeObject



13
14
15
16
17
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 13

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

#get_contentObject



27
28
29
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 27

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

#validate_commandObject



8
9
10
11
# File 'lib/docman/commands/git_repo_provider_cmd.rb', line 8

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