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

Methods included from OptionGroup

all, all_options, except, merge, select, select_with_defaults

Class Method Details

.all_optionsObject



17
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
# File 'lib/pindo/options/groups/git_options.rb', line 17

def self.all_options
  @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'
    )
  }
end

.parse_create_tag_type(value) ⇒ Symbol

将命令行参数值转换为 CreateTagType 常量

Parameters:

  • value (String)

    命令行参数值 (new/recreate/none)

Returns:

  • (Symbol)

    CreateTagType 常量值



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/pindo/options/groups/git_options.rb', line 101

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_version_increase_type(value) ⇒ Symbol

将命令行参数值转换为 VersionIncreaseType 常量

Parameters:

  • value (String)

    命令行参数值 (main/mini/patch)

Returns:

  • (Symbol)

    VersionIncreaseType 常量值



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/pindo/options/groups/git_options.rb', line 85

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