Class: Pindo::TaskSystem::GitCommitTask

Inherits:
GitTask show all
Defined in:
lib/pindo/module/task/model/git/git_commit_task.rb

Overview

Git 提交任务负责检查并提交仓库的未提交修改

Instance Attribute Summary

Attributes inherited from GitTask

#build_number, #build_version, #commit_hash, #git_root_path, #project_path, #release_branch, #tag_pre, #tag_type, #ver_inc

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #skip_count, #started_at, #status, #task_key, #task_manager, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GitTask

default_retry_delay, default_retry_mode, #required_resources, task_type, task_type_name

Methods inherited from PindoTask

#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, default_retry_delay, default_retry_mode, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #release_resource, #release_resources, #required_resources, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type, #with_resource, #with_resources

Constructor Details

#initialize(project_path, options = {}) ⇒ GitCommitTask

初始化 Git 提交任务版本号计算逻辑:

1. 

Parameters:

  • project_path (String)

    项目路径

  • options (Hash) (defaults to: {})

    选项(与 GitOptions 参数名一致)

    • release_branch: 发布分支名称,默认 ‘master’

    • ver_inc: 版本号增加类型,默认 :mini

    • tag_type: 创建tag类型,默认 :new

    • tag_pre: tag前缀,默认 ‘v’

    • fixed_version: 外部指定的固定版本号

    • process_type: 未提交文件的处理方式 (‘skip’, ‘commit’, ‘reset’, ‘stash’),默认 ‘skip’

    • commit_message: 提交消息,默认 ‘build: 构建产生提交’



37
38
39
40
41
42
43
44
45
46
# File 'lib/pindo/module/task/model/git/git_commit_task.rb', line 37

def initialize(project_path, options = {})
  # GitCommitTask 特有的属性
  @fixed_version = options[:fixed_version]  # 外部指定的固定版本号
  @process_type = options[:process_type] || Pindo::UncommittedFilesProcessType::SKIP # 默认跳过
  @commit_message = options[:commit_message] || 'build: 构建产生提交' # 默认提交消息

  options[:project_path] = project_path
  # 调用基类初始化(基类会设置 release_branch, ver_inc, tag_type, tag_pre 等通用属性)
  super("Git仓库文件提交检查", options)
end

Class Method Details

.default_retry_countObject

重试配置:失败后重试 1 次



17
18
19
# File 'lib/pindo/module/task/model/git/git_commit_task.rb', line 17

def self.default_retry_count
  2
end

.task_keyObject

任务键



12
13
14
# File 'lib/pindo/module/task/model/git/git_commit_task.rb', line 12

def self.task_key
  :git_commit
end

Instance Method Details

#validateObject



48
49
50
51
52
53
# File 'lib/pindo/module/task/model/git/git_commit_task.rb', line 48

def validate
  super
  # 不再验证是否为 Git 仓库,由 do_work 中处理
  # 非 Git 仓库目录会跳过检查并成功返回
  true
end