Class: KCommercial::Resources::ResourcesUpdate

Inherits:
Object
  • Object
show all
Defined in:
lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb

Overview

自动同步到仓库

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResourcesUpdate

Returns a new instance of ResourcesUpdate.



6
7
# File 'lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb', line 6

def initialize
end

Class Method Details

.can_auto_push?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb', line 8

def self.can_auto_push?
  change_files = KCommercial::KCPipeline::KCGit.git.status.changed()
  change_files.delete('Gemfile.lock')
  change_files.empty?
end

.pushObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb', line 14

def self.push
  if !should_push
    KCommercial::KCPipeline::KCGit.git.add('.')
    KCommercial::KCPipeline::KCGit.git.commit("chore(matrix,resource): 自动更新资源组件")
    branch_name = KCommercial::KCPipeline::KCGit.git.current_branch || ''
    KCommercial::KCPipeline::KCGit.git.push('origin',branch_name) unless branch_name.empty?
  else
    KCommercial::UI.info("资源未更新")
    exit!(0)
  end
end

.should_pushObject



26
27
28
29
30
# File 'lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb', line 26

def self.should_push
  change_files = KCommercial::KCPipeline::KCGit.git.status.changed()
  change_files.delete('Gemfile.lock')
  change_files.empty?
end