Module: Pindo::Options::GitOptions
- Extended by:
- OptionGroup
- Defined in:
- lib/pindo/options/groups/git_options.rb
Overview
Git 版本管理参数组定义 Git tag 和版本控制相关的参数
Constant Summary collapse
- VERSION_INCREASE_TYPES =
版本增加类型的有效值
%w[main mini patch].freeze
- CREATE_TAG_TYPES =
创建 Tag 类型的有效值
%w[new recreate none].freeze
Class Method Summary collapse
- .all_options ⇒ Object
-
.parse_create_tag_type(value) ⇒ Symbol
将命令行参数值转换为 CreateTagType 常量.
-
.parse_git_commit_type(value) ⇒ Symbol?
解析 –git-commit 参数并转换为枚举常量.
-
.parse_version_increase_type(value) ⇒ Symbol
将命令行参数值转换为 VersionIncreaseType 常量.
Methods included from OptionGroup
all, all_options, except, merge, select, select_with_defaults
Class Method Details
.all_options ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pindo/options/groups/git_options.rb', line 18 def self. @all_options ||= { ver_inc: OptionItem.new( key: :ver_inc, name: '版本增加方式', description: '版本号增加方式: main(大版本), mini(小版本), patch(补丁版本)', type: String, env_name: 'PINDO_VERSION_INCREASE', default_value: 'mini', aliases: [:version_increase], optional: true, cacheable: true, # 存入文件缓存 verify_block: proc do |value| unless VERSION_INCREASE_TYPES.include?(value.to_s.downcase) raise "版本增加类型错误: #{value},必须是 main、mini 或 patch 之一" end end, example: 'pindo ios autobuild --ver_inc=mini' ), tag_type: OptionItem.new( key: :tag_type, name: 'Tag创建方式', description: '创建Tag方式: new(新建tag), recreate(重新创建当前tag), none(不创建tag)', type: String, env_name: 'PINDO_CREATE_TAG', default_value: 'new', aliases: [:create_tag], optional: true, cacheable: true, # 存入文件缓存 verify_block: proc do |value| unless CREATE_TAG_TYPES.include?(value.to_s.downcase) raise "创建Tag类型错误: #{value},必须是 new、recreate 或 none 之一" end end, example: 'pindo ios autobuild --tag_type=new' ), tag_pre: OptionItem.new( key: :tag_pre, name: 'Tag前缀', description: 'Git tag 前缀', type: String, env_name: 'PINDO_TAG_PREFIX', default_value: 'v', aliases: [:tag_prefix], optional: true, cacheable: true, # 存入文件缓存 example: 'pindo ios autobuild --tag_pre=v' ), release_branch: OptionItem.new( key: :release_branch, name: 'Release分支', description: 'Release 分支名称', type: String, env_name: 'PINDO_RELEASE_BRANCH', default_value: 'master', optional: true, cacheable: true, # 存入文件缓存 example: 'pindo ios autobuild --release_branch=main' ), git_commit: OptionItem.new( key: :git_commit, name: 'Git 未提交处理方式', description: '处理未提交文件的方式: commit/skip/reset/stash/exit', type: String, env_name: 'PINDO_GIT_COMMIT', default_value: nil, optional: true, cacheable: false, verify_block: proc do |value| allowed = %w[commit skip reset delete stash exit resetde discard] unless allowed.include?(value.to_s.downcase) raise "git_commit 值错误: #{value}, 必须是 #{allowed.join(', ')} 之一" end end, example: 'pindo unity autobuild --git-commit=skip' ) } end |
.parse_create_tag_type(value) ⇒ Symbol
将命令行参数值转换为 CreateTagType 常量
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/pindo/options/groups/git_options.rb', line 141 def self.parse_create_tag_type(value) case value.to_s.downcase when 'new', 'create' Pindo::CreateTagType::NEW when 'recreate', 'retag' Pindo::CreateTagType::RECREATE when 'none', 'skip', 'dont' Pindo::CreateTagType::NONE else Pindo::CreateTagType::NEW end end |
.parse_git_commit_type(value) ⇒ Symbol?
解析 –git-commit 参数并转换为枚举常量
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/pindo/options/groups/git_options.rb', line 120 def self.parse_git_commit_type(value) return nil if value.nil? case value.to_s.downcase when 'commit', 'comm' Pindo::UncommittedFilesProcessType::COMMIT when 'skip', 'none', 'dont' Pindo::UncommittedFilesProcessType::SKIP when 'reset', 'delete', 'resetde', 'discard' Pindo::UncommittedFilesProcessType::RESET when 'stash' Pindo::UncommittedFilesProcessType::STASH when 'exit' Pindo::UncommittedFilesProcessType::EXIT else nil end end |
.parse_version_increase_type(value) ⇒ Symbol
将命令行参数值转换为 VersionIncreaseType 常量
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/pindo/options/groups/git_options.rb', line 104 def self.parse_version_increase_type(value) case value.to_s.downcase when 'main', 'major' Pindo::VersionIncreaseType::MAIN when 'mini', 'minor' Pindo::VersionIncreaseType::MINI when 'patch' Pindo::VersionIncreaseType::PATCH else Pindo::VersionIncreaseType::MINI end end |