Class: Pindo::TaskSystem::GitTask
- Defined in:
- lib/pindo/module/task/model/git_task.rb
Overview
Git 任务基类所有 Git 相关任务的父类,提供通用的 Git 操作和配置
Direct Known Subclasses
Instance Attribute Summary collapse
-
#build_number ⇒ Object
readonly
Returns the value of attribute build_number.
-
#build_version ⇒ Object
readonly
Returns the value of attribute build_version.
-
#commit_hash ⇒ Object
readonly
Returns the value of attribute commit_hash.
-
#git_root_path ⇒ Object
readonly
Returns the value of attribute git_root_path.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#release_branch ⇒ Object
readonly
Returns the value of attribute release_branch.
-
#tag_pre ⇒ Object
readonly
Returns the value of attribute tag_pre.
-
#tag_type ⇒ Object
readonly
Returns the value of attribute tag_type.
-
#ver_inc ⇒ Object
readonly
Returns the value of attribute 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
- .default_retry_count ⇒ Object
- .default_retry_delay ⇒ Object
-
.default_retry_mode ⇒ Object
Git 任务默认重试配置.
-
.task_type ⇒ Object
Git 任务类型.
-
.task_type_name ⇒ Object
Git 任务类型显示名称.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ GitTask
constructor
A new instance of GitTask.
-
#required_resources ⇒ Object
声明所需资源 - 基于仓库路径锁定 Git 操作 确保同一仓库的 Git 任务串行执行,避免并发冲突.
-
#validate ⇒ Object
验证项目路径.
Methods inherited from PindoTask
#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, #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, #reset_for_retry, #retryable?, #running?, #should_retry?, task_key, #with_resource, #with_resources
Constructor Details
#initialize(name, options = {}) ⇒ GitTask
Returns a new instance of GitTask.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pindo/module/task/model/git_task.rb', line 14 def initialize(name, = {}) @project_path = [:project_path] ? File.([:project_path]) : nil # Git 版本管理相关属性(子类可以覆盖默认值) @release_branch = [:release_branch] || 'master' @ver_inc = [:ver_inc] || Pindo::VersionIncreaseType::MINI @tag_type = [:tag_type] || Pindo::CreateTagType::NEW @tag_pre = [:tag_pre] || 'v' # 版本信息(由子类在 do_work 中赋值) @build_version = nil @build_number = nil @commit_hash = nil # 通过 project_path 获取 git_root_path @git_root_path = @project_path ? Pindo::GitHandler.git_root_directory(local_repo_dir: @project_path) : nil super(name, ) end |
Instance Attribute Details
#build_number ⇒ Object (readonly)
Returns the value of attribute build_number.
12 13 14 |
# File 'lib/pindo/module/task/model/git_task.rb', line 12 def build_number @build_number end |
#build_version ⇒ Object (readonly)
Returns the value of attribute build_version.
12 13 14 |
# File 'lib/pindo/module/task/model/git_task.rb', line 12 def build_version @build_version end |
#commit_hash ⇒ Object (readonly)
Returns the value of attribute commit_hash.
12 13 14 |
# File 'lib/pindo/module/task/model/git_task.rb', line 12 def commit_hash @commit_hash end |
#git_root_path ⇒ Object (readonly)
Returns the value of attribute git_root_path.
10 11 12 |
# File 'lib/pindo/module/task/model/git_task.rb', line 10 def git_root_path @git_root_path end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
10 11 12 |
# File 'lib/pindo/module/task/model/git_task.rb', line 10 def project_path @project_path end |
#release_branch ⇒ Object (readonly)
Returns the value of attribute release_branch.
11 12 13 |
# File 'lib/pindo/module/task/model/git_task.rb', line 11 def release_branch @release_branch end |
#tag_pre ⇒ Object (readonly)
Returns the value of attribute tag_pre.
11 12 13 |
# File 'lib/pindo/module/task/model/git_task.rb', line 11 def tag_pre @tag_pre end |
#tag_type ⇒ Object (readonly)
Returns the value of attribute tag_type.
11 12 13 |
# File 'lib/pindo/module/task/model/git_task.rb', line 11 def tag_type @tag_type end |
#ver_inc ⇒ Object (readonly)
Returns the value of attribute ver_inc.
11 12 13 |
# File 'lib/pindo/module/task/model/git_task.rb', line 11 def ver_inc @ver_inc end |
Class Method Details
.default_retry_count ⇒ Object
49 50 51 |
# File 'lib/pindo/module/task/model/git_task.rb', line 49 def self.default_retry_count 0 # 默认不重试 end |
.default_retry_delay ⇒ Object
53 54 55 |
# File 'lib/pindo/module/task/model/git_task.rb', line 53 def self.default_retry_delay 5 # 默认延迟 5 秒 end |
.default_retry_mode ⇒ Object
Git 任务默认重试配置
45 46 47 |
# File 'lib/pindo/module/task/model/git_task.rb', line 45 def self.default_retry_mode RetryMode::IMMEDIATE # 立即重试 end |
.task_type ⇒ Object
Git 任务类型
35 36 37 |
# File 'lib/pindo/module/task/model/git_task.rb', line 35 def self.task_type :git end |
.task_type_name ⇒ Object
Git 任务类型显示名称
40 41 42 |
# File 'lib/pindo/module/task/model/git_task.rb', line 40 def self.task_type_name "Git操作" end |
Instance Method Details
#required_resources ⇒ Object
声明所需资源 - 基于仓库路径锁定 Git 操作确保同一仓库的 Git 任务串行执行,避免并发冲突
71 72 73 |
# File 'lib/pindo/module/task/model/git_task.rb', line 71 def required_resources (super || []) + [{ type: :git, directory: @git_root_path }] end |
#validate ⇒ Object
验证项目路径
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pindo/module/task/model/git_task.rb', line 58 def validate super unless @project_path && Dir.exist?(@project_path) @error = "项目路径不存在:#{@project_path}" return false end true end |