pindo 5.14.7 → 5.14.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e61c4fa7bc1f944011a7d2da6ea5f88e6964cf4156fbfc820a82f87f8376b15
4
- data.tar.gz: '0826f4b21c1fdd8145763b8357dddfa7f6c06a461b128bb458b7c75886ba5208'
3
+ metadata.gz: 68b5c0f86d764eff85c26932fb2ba31d4e7078adca1d216b9c6e40901cc5408c
4
+ data.tar.gz: 1389910ee8c9fd7f571634001816e8e5776ead59cf59c65fb806edf57b1eb020
5
5
  SHA512:
6
- metadata.gz: a1379dd0f212e82aad3c889d9c06374810441728700616d9a2293c647bbe0272318d744dcfd4056edf69d8bde847a9394225c334a3909e419f34321d38d9f29f
7
- data.tar.gz: df9c68524dbdbd81f29e3134c9b1a25de3e6fc57e29346b5beae93bcccb8ac1186bbfe7e3f4a86dbfb81ebc5356f91eeb852cf9a6f504144225c3715e9a63975
6
+ metadata.gz: 3cd5a36c2d7fc0a607c53f47595cf129c05129066bc77894d984b1e4e639ba017f0045edf224efd1b12352521bf200a9001a7cef1ebb9852d81f3087b3e4b72a
7
+ data.tar.gz: 66c0fe689c8bd6ba4c51b4db4f75486fd33941a73d9f47396699e32adcb8e96d13b0dd6e427c653e255bdf54d9c1907504a8059bba605e05cdc91eb1b962d487
@@ -662,8 +662,12 @@ module Pindo
662
662
 
663
663
  # 获取最新的符合规范的 commit
664
664
  # @param project_dir [String] 项目目录路径
665
+ # @param tag_prefix [String] tag前缀,用于检查 HEAD 是否有版本 tag,默认 'v'
665
666
  # @return [Hash] 包含 :commit_id, :commit_time, :commit_desc
666
- def get_latest_conventional_commit(project_dir:nil)
667
+ # 优先级:
668
+ # 1. 如果 HEAD 存在版本 tag,直接返回 HEAD(认为有 tag 的 commit 是有效的发布节点)
669
+ # 2. 否则,返回最新的符合 Conventional Commits 规范的提交
670
+ def get_latest_conventional_commit(project_dir:nil, tag_prefix: 'v')
667
671
  result = {
668
672
  commit_id: nil,
669
673
  commit_time: nil,
@@ -672,9 +676,27 @@ module Pindo
672
676
 
673
677
  return result if project_dir.nil? || !File.exist?(project_dir)
674
678
 
675
- Dir.chdir(project_dir) do
676
- # 获取最近 15 条 commit 历史
677
- output = `git log -15 --format="%H|%ci|%s" 2>/dev/null`.strip
679
+ # 获取 git 根目录
680
+ git_root = git_root_directory(local_repo_dir: project_dir)
681
+ return result unless git_root
682
+
683
+ begin
684
+ # 优先级 1: 检查 HEAD 是否有版本 tag
685
+ if head_has_version_tag?(project_dir: git_root, tag_prefix: tag_prefix)
686
+ # HEAD 有版本 tag,直接返回 HEAD 的 commit 信息
687
+ head_info = git!(%W(-C #{git_root} log -1 --format=%H|%ci|%s HEAD)).strip
688
+ if !head_info.empty?
689
+ parts = head_info.split('|', 3)
690
+ result[:commit_id] = parts[0]
691
+ result[:commit_time] = parts[1]
692
+ result[:commit_desc] = parts[2]
693
+ puts " HEAD 存在版本 tag,使用 HEAD commit: #{result[:commit_desc]}"
694
+ return result
695
+ end
696
+ end
697
+
698
+ # 优先级 2: 获取最近 15 条 commit 历史(排除 merge commits)
699
+ output = git!(%W(-C #{git_root} log -15 --no-merges --format=%H|%ci|%s)).strip
678
700
 
679
701
  if output.empty?
680
702
  Funlog.instance.warning("未找到 git commit 历史")
@@ -691,13 +713,16 @@ module Pindo
691
713
  }
692
714
  end
693
715
 
694
- # 定义符合规范的提交类型
695
- valid_prefixes = ['feat:', 'fix:', 'docs:', 'style:', 'refactor:', 'perf:', 'test:', 'build:', 'ci:', 'chore:', 'revert:']
716
+ # 定义符合规范的提交类型(Conventional Commits 规范)
717
+ valid_types = ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert']
696
718
 
697
- # 筛选符合规范的提交
719
+ # 筛选符合规范的提交(支持 type: 和 type(scope): 两种格式)
698
720
  conventional_commits = commits.select do |commit|
699
- desc = commit[:commit_desc].to_s.strip
700
- valid_prefixes.any? { |prefix| desc.downcase.start_with?(prefix) }
721
+ desc = commit[:commit_desc].to_s.strip.downcase
722
+ # 匹配 "type:" 或 "type(" 格式(允许 scope)
723
+ valid_types.any? do |type|
724
+ desc.start_with?("#{type}:") || desc.start_with?("#{type}(")
725
+ end
701
726
  end
702
727
 
703
728
  if conventional_commits.empty?
@@ -717,6 +742,9 @@ module Pindo
717
742
 
718
743
  puts " 找到符合规范的提交: #{result[:commit_desc]}"
719
744
  end
745
+ rescue StandardError => e
746
+ Funlog.instance.warning("获取 conventional commit 失败: #{e.message}")
747
+ return result
720
748
  end
721
749
 
722
750
  result
@@ -780,6 +808,20 @@ module Pindo
780
808
  new_tag
781
809
  end
782
810
 
811
+ # 检查 HEAD 是否已有版本 tag
812
+ # @param project_dir [String] 项目目录
813
+ # @param tag_prefix [String] tag前缀,默认 'v'
814
+ # @return [Boolean] HEAD 是否有版本 tag
815
+ def head_has_version_tag?(project_dir:, tag_prefix: 'v')
816
+ latest_tag = get_latest_version_tag(
817
+ project_dir: project_dir,
818
+ tag_prefix: tag_prefix
819
+ )
820
+ return false if latest_tag.nil?
821
+
822
+ is_tag_at_head?(git_root_dir: project_dir, tag_name: latest_tag)
823
+ end
824
+
783
825
  # 检查仓库是否有未提交的更改(包括未暂存和已暂存的更改)
784
826
  # @param git_root_dir [String] 项目目录路径
785
827
  # @return [Boolean] 如果有未提交的更改返回true,否则返回false
@@ -804,8 +846,8 @@ module Pindo
804
846
  return false if git_root_dir.nil? || tag_name.nil?
805
847
 
806
848
  begin
807
- # 获取tagcommit hash
808
- tag_commit = git!(%W(-C #{git_root_dir} rev-parse #{tag_name})).strip
849
+ # 获取tag指向的commit hash(使用^{commit}解引用,支持annotated tag和lightweight tag)
850
+ tag_commit = git!(%W(-C #{git_root_dir} rev-parse #{tag_name}^{commit})).strip
809
851
  # 获取HEAD的commit hash
810
852
  head_commit = git!(%W(-C #{git_root_dir} rev-parse HEAD)).strip
811
853
 
@@ -411,12 +411,11 @@ module Pindo
411
411
  puts "key_id : #{key_id}"
412
412
  puts "private_key : #{private_key}"
413
413
 
414
- AppStoreDevApi.config = {
414
+ @app_store_connect = AppStoreDevApi::Client.new(
415
415
  issuer_id: issuer_id,
416
416
  key_id: key_id,
417
417
  private_key: private_key
418
- }
419
- @app_store_connect = AppStoreDevApi::Client.new
418
+ )
420
419
  end
421
420
  end
422
421
 
@@ -236,20 +236,25 @@ module Pindo
236
236
 
237
237
  # 获取Build号(从commit hash转换而来)
238
238
  # @param project_dir [String] 项目目录路径
239
- # @return [Integer] Build号(6位16进制转10进制)
239
+ # @return [Integer, String] 返回 build_number 和 commit_hash
240
+ # - build_number: Build号(commit hash前6位16进制转10进制)
241
+ # - commit_hash: 完整的commit hash(40位)
240
242
  def get_build_number_from_commit(project_dir: nil)
241
243
  raise ArgumentError, "项目目录不能为空" if project_dir.nil?
242
244
 
243
245
  # 获取git根目录
244
246
  git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: project_dir)
245
- return 1 unless git_root
247
+ return 1, nil unless git_root
246
248
 
247
249
  begin
248
- # 获取当前HEADcommit hash前6位
249
- commit_hash = Pindo::GitHandler.git!(%W(-C #{git_root} rev-parse HEAD)).strip[0..5]
250
+ # 获取当前HEAD的完整commit hash
251
+ full_commit_hash = Pindo::GitHandler.git!(%W(-C #{git_root} rev-parse HEAD)).strip
252
+
253
+ # 取前6位计算build_number
254
+ short_hash = full_commit_hash[0..5]
250
255
 
251
256
  # 将16进制转换为10进制
252
- build_number = commit_hash.to_i(16)
257
+ build_number = short_hash.to_i(16)
253
258
 
254
259
  # 确保在Android versionCode安全范围内(最大值为2^31-1)
255
260
  max_value = 2**31 - 1
@@ -258,11 +263,11 @@ module Pindo
258
263
  # 确保build_number不为0
259
264
  build_number = 1 if build_number == 0
260
265
 
261
- build_number
266
+ return build_number, full_commit_hash
262
267
  rescue StandardError => e
263
268
  Funlog.instance.fancyinfo_error("获取commit hash失败: #{e.message}")
264
269
  # 如果获取失败,返回基于时间戳的默认值
265
- Time.now.to_i % 1000000 + 1
270
+ return Time.now.to_i % 1000000 + 1, nil
266
271
  end
267
272
  end
268
273
 
@@ -304,7 +309,7 @@ module Pindo
304
309
  current_version
305
310
  when Pindo::CreateTagType::NEW
306
311
  # 创建新tag,需要检查HEAD是否已有tag
307
- if head_has_version_tag?(project_dir: project_dir, tag_prefix: tag_prefix)
312
+ if Pindo::GitHandler.head_has_version_tag?(project_dir: project_dir, tag_prefix: tag_prefix)
308
313
  # HEAD已有tag,不需要创建新tag,使用当前版本号
309
314
  Funlog.instance.fancyinfo_success("HEAD已存在tag,使用当前版本号: #{current_version}")
310
315
  current_version
@@ -337,19 +342,6 @@ module Pindo
337
342
  end
338
343
  end
339
344
 
340
- # 检查HEAD是否已有版本tag
341
- # @param project_dir [String] 项目目录
342
- # @param tag_prefix [String] tag前缀
343
- # @return [Boolean] HEAD是否有tag
344
- def head_has_version_tag?(project_dir:, tag_prefix: 'v')
345
- latest_tag = Pindo::GitHandler.get_latest_version_tag(
346
- project_dir: project_dir,
347
- tag_prefix: tag_prefix
348
- )
349
- return false if latest_tag.nil?
350
-
351
- Pindo::GitHandler.is_tag_at_head?(git_root_dir: project_dir, tag_name: latest_tag)
352
- end
353
345
 
354
346
  # 创建并推送 Tag
355
347
  # @param project_dir [String] 项目目录
@@ -146,14 +146,15 @@ module Pindo
146
146
 
147
147
  if git_root
148
148
  # 是 Git 仓库,自己计算版本号
149
- build_number = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
149
+ build_number, commit_hash = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
150
150
  build_version = git_repo_helper.calculate_build_version(
151
151
  project_dir: @project_path,
152
152
  tag_prefix: @tag_pre,
153
153
  create_tag_type: @tag_type,
154
154
  version_increase_type: @ver_inc
155
155
  )
156
- Funlog.instance.fancyinfo_success("自己计算版本号: #{build_version}, Build: #{build_number}")
156
+ commit_short = commit_hash ? commit_hash[0..7] : "unknown"
157
+ Funlog.instance.fancyinfo_success("自己计算版本号: #{build_version}, Build: #{build_number}, Commit: #{commit_short}")
157
158
  else
158
159
  # 不是 Git 仓库且没有从 GitCommitTask 获取到版本号,跳过版本更新
159
160
  Funlog.warning("非Git仓库且未从 GitCommitTask 获取到版本号,保持工程原有版本号")
@@ -159,14 +159,15 @@ module Pindo
159
159
 
160
160
  if git_root
161
161
  # 是 Git 仓库,自己计算版本号
162
- build_number = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
162
+ build_number, commit_hash = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
163
163
  build_version = git_repo_helper.calculate_build_version(
164
164
  project_dir: @project_path,
165
165
  tag_prefix: @tag_pre,
166
166
  create_tag_type: @tag_type,
167
167
  version_increase_type: @ver_inc
168
168
  )
169
- Funlog.instance.fancyinfo_success("自己计算版本号: #{build_version}, Build: #{build_number}")
169
+ commit_short = commit_hash ? commit_hash[0..7] : "unknown"
170
+ Funlog.instance.fancyinfo_success("自己计算版本号: #{build_version}, Build: #{build_number}, Commit: #{commit_short}")
170
171
  else
171
172
  # 不是 Git 仓库且没有从 GitCommitTask 获取到版本号,跳过版本更新
172
173
  Funlog.warning("非Git仓库且未从 GitCommitTask 获取到版本号,保持工程原有版本号")
@@ -7,9 +7,6 @@ module Pindo
7
7
  # Git 提交任务
8
8
  # 负责检查并提交仓库的未提交修改
9
9
  class GitCommitTask < GitTask
10
- attr_reader :release_branch, :ver_inc, :tag_type, :tag_pre
11
- attr_reader :build_version, :build_number
12
-
13
10
  # 任务键
14
11
  def self.task_key
15
12
  :git_commit
@@ -37,18 +34,13 @@ module Pindo
37
34
  # 2. 执行 check_gitignore(可能创建新提交)
38
35
  # 3. 最终使用 fixed_version(如果有)或计算新版本号
39
36
  def initialize(project_path, options = {})
40
- @release_branch = options[:release_branch] || 'master'
41
- @ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
42
- @tag_type = options[:tag_type] || Pindo::CreateTagType::NEW
43
- @tag_pre = options[:tag_pre] || 'v'
37
+ # GitCommitTask 特有的属性
44
38
  @fixed_version = options[:fixed_version] # 外部指定的固定版本号
45
39
  @process_type = options[:process_type] || 'skip' # 默认跳过
46
40
  @commit_message = options[:commit_message] || 'build: 构建产生提交' # 默认提交消息
47
41
 
48
- @build_version = nil
49
- @build_number = nil
50
42
  options[:project_path] = project_path
51
-
43
+ # 调用基类初始化(基类会设置 release_branch, ver_inc, tag_type, tag_pre 等通用属性)
52
44
  super("Git仓库文件提交检查", options)
53
45
  end
54
46
 
@@ -79,7 +71,7 @@ module Pindo
79
71
  # 1. 如果 fixed_version 为 nil,尝试从 HEAD 的 tag 获取版本
80
72
  # 必须在 check_gitignore 之前检查,因为 check_gitignore 可能创建提交导致 HEAD 移动
81
73
  if (@fixed_version.nil? || @fixed_version.empty?) &&
82
- git_repo_helper.head_has_version_tag?(project_dir: root_dir, tag_prefix: @tag_pre) &&
74
+ Pindo::GitHandler.head_has_version_tag?(project_dir: root_dir, tag_prefix: @tag_pre) &&
83
75
  !Pindo::GitHandler.has_uncommitted_changes?(git_root_dir: root_dir)
84
76
  # HEAD 有 tag 且工作目录干净,使用 tag 的版本
85
77
  latest_tag = Pindo::GitHandler.get_latest_version_tag(
@@ -87,7 +79,7 @@ module Pindo
87
79
  tag_prefix: @tag_pre
88
80
  )
89
81
  @fixed_version = latest_tag.sub(/^#{@tag_pre}/, '') if latest_tag
90
- Funlog.instance.fancyinfo_success("HEAD 存在 tag 且工作目录干净,设置 fixed_version: #{@fixed_version}")
82
+ Funlog.instance.fancyinfo_success("HEAD 存在 tag 且工作目录干净,会强制使用HEAD上的版本号: #{@fixed_version}")
91
83
  end
92
84
 
93
85
  # 2. 检查并修复 .gitignore(可能创建新提交,但 fixed_version 已经确定)
@@ -141,19 +133,21 @@ module Pindo
141
133
  # 优先级 1: 如果指定了 fixed_version(外部传入或从 HEAD tag 获取),使用它
142
134
  if @fixed_version && !@fixed_version.empty?
143
135
  @build_version = @fixed_version
144
- @build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
145
- Funlog.instance.fancyinfo_success("使用 fixed_version: #{@build_version}, Build: #{@build_number}")
136
+ @build_number, @commit_hash = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
137
+ commit_short = @commit_hash ? @commit_hash[0..7] : "unknown"
138
+ Funlog.instance.fancyinfo_success("Version: #{@build_version}, Build: #{@build_number}, Commit: #{commit_short}")
146
139
 
147
140
  # 优先级 2: 计算新版本号
148
141
  else
149
- @build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
142
+ @build_number, @commit_hash = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
150
143
  @build_version = git_repo_helper.calculate_build_version(
151
144
  project_dir: root_dir,
152
145
  tag_prefix: @tag_pre,
153
146
  create_tag_type: @tag_type,
154
147
  version_increase_type: @ver_inc
155
148
  )
156
- Funlog.instance.fancyinfo_success("计算新版本号: #{@build_version}, Build: #{@build_number}")
149
+ commit_short = @commit_hash ? @commit_hash[0..7] : "unknown"
150
+ Funlog.instance.fancyinfo_success("Version: #{@build_version}, Build: #{@build_number}, Commit: #{commit_short}")
157
151
  end
158
152
 
159
153
  # 9. 还原 stash(如果之前有 stash)
@@ -175,41 +169,6 @@ module Pindo
175
169
  message: "Git 提交检查完成"
176
170
  }
177
171
  end
178
-
179
- # 构建任务参数(供其他任务使用)
180
- def build_task_param
181
- return {} unless @status == TaskStatus::SUCCESS
182
-
183
- # 如果不是 Git 仓库,返回空参数(让依赖任务知道没有有效数据)
184
- return {} if @build_version.nil? || @build_number.nil?
185
-
186
- param = {
187
- release_branch: @release_branch,
188
- build_version: @build_version,
189
- build_number: @build_number,
190
- tag_pre: @tag_pre,
191
- tag_type: @tag_type,
192
- ver_inc: @ver_inc
193
- }
194
-
195
- # 添加 git commit 信息(供 JPSUploadMediaTask 等任务使用)
196
- if @git_root_path
197
- begin
198
- # 获取当前 HEAD commit 信息
199
- git_commit_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: @git_root_path)
200
- if git_commit_info
201
- param[:git_commit_id] = git_commit_info[:commit_id]
202
- param[:git_commit_time] = git_commit_info[:commit_time]
203
- param[:git_commit_desc] = git_commit_info[:commit_desc]
204
- end
205
- rescue => e
206
- # 如果获取失败,不影响主流程
207
- Funlog.instance.fancyinfo_warning("获取 git commit 信息失败: #{e.message}") if ENV['PINDO_DEBUG']
208
- end
209
- end
210
-
211
- param
212
- end
213
172
  end
214
173
  end
215
174
  end
@@ -7,9 +7,6 @@ module Pindo
7
7
  # Git 标签任务
8
8
  # 负责在构建成功后创建 Git 标签
9
9
  class GitTagTask < GitTask
10
- attr_reader :release_branch, :ver_inc, :tag_type, :tag_pre
11
- attr_reader :build_version, :build_number
12
-
13
10
  # 任务键
14
11
  def self.task_key
15
12
  :git_tag
@@ -29,15 +26,8 @@ module Pindo
29
26
  # - tag_pre: tag前缀,默认 'v'
30
27
  # 注意:版本号从 GitCommitTask 获取(GitTagTask 必须依赖 GitCommitTask)
31
28
  def initialize(project_path, options = {})
32
- @release_branch = options[:release_branch] || 'master'
33
- @ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
34
- @tag_type = options[:tag_type] || Pindo::CreateTagType::NEW
35
- @tag_pre = options[:tag_pre] || 'v'
36
-
37
- @build_version = nil
38
- @build_number = nil
39
29
  options[:project_path] = project_path
40
-
30
+ # 调用基类初始化(基类会设置所有通用属性)
41
31
  super("Git仓库打Tag", options)
42
32
  end
43
33
 
@@ -98,14 +88,15 @@ module Pindo
98
88
 
99
89
  # 优先级 2: 自己计算(降级方案,用于向后兼容或 GitCommitTask 无有效数据)
100
90
  else
101
- @build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
91
+ @build_number, @commit_hash = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
102
92
  @build_version = git_repo_helper.calculate_build_version(
103
93
  project_dir: root_dir,
104
94
  tag_prefix: @tag_pre,
105
95
  create_tag_type: @tag_type,
106
96
  version_increase_type: @ver_inc
107
97
  )
108
- Funlog.instance.fancyinfo_warning("未找到 GitCommitTask 依赖,降级为自己计算版本号: #{@build_version}")
98
+ commit_short = @commit_hash ? @commit_hash[0..7] : "unknown"
99
+ Funlog.instance.fancyinfo_warning("未找到 GitCommitTask 依赖,降级为自己计算版本号: #{@build_version}, Build: #{@build_number}, Commit: #{commit_short}")
109
100
  end
110
101
 
111
102
  # 4. 创建并推送 Tag
@@ -1,5 +1,6 @@
1
1
  require 'pindo/module/task/pindo_task'
2
2
  require 'pindo/base/git_handler'
3
+ require 'pindo/module/build/git_repo_helper'
3
4
 
4
5
  module Pindo
5
6
  module TaskSystem
@@ -7,10 +8,23 @@ module Pindo
7
8
  # 所有 Git 相关任务的父类,提供通用的 Git 操作和配置
8
9
  class GitTask < PindoTask
9
10
  attr_reader :project_path, :git_root_path
11
+ attr_reader :release_branch, :ver_inc, :tag_type, :tag_pre
12
+ attr_reader :build_version, :build_number, :commit_hash
10
13
 
11
14
  def initialize(name, options = {})
12
15
  @project_path = options[:project_path] ? File.expand_path(options[:project_path]) : nil
13
16
 
17
+ # Git 版本管理相关属性(子类可以覆盖默认值)
18
+ @release_branch = options[:release_branch] || 'master'
19
+ @ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
20
+ @tag_type = options[:tag_type] || Pindo::CreateTagType::NEW
21
+ @tag_pre = options[:tag_pre] || 'v'
22
+
23
+ # 版本信息(由子类在 do_work 中赋值)
24
+ @build_version = nil
25
+ @build_number = nil
26
+ @commit_hash = nil
27
+
14
28
  # 通过 project_path 获取 git_root_path
15
29
  @git_root_path = @project_path ? Pindo::GitHandler.git_root_directory(local_repo_dir: @project_path) : nil
16
30
 
@@ -76,6 +90,41 @@ module Pindo
76
90
  return nil unless @git_root_path
77
91
  Pindo::GitHandler.git!(%W(-C #{@git_root_path} rev-parse --abbrev-ref HEAD)).strip
78
92
  end
93
+
94
+ # 构建任务参数(供其他任务使用)
95
+ def build_task_param
96
+ return {} unless @status == TaskStatus::SUCCESS
97
+
98
+ # 如果不是 Git 仓库,返回空参数(让依赖任务知道没有有效数据)
99
+ return {} if @build_version.nil? || @build_number.nil?
100
+
101
+ param = {
102
+ release_branch: @release_branch,
103
+ build_version: @build_version,
104
+ build_number: @build_number,
105
+ tag_pre: @tag_pre,
106
+ tag_type: @tag_type,
107
+ ver_inc: @ver_inc
108
+ }
109
+
110
+ # 添加 git commit 信息(供 JPSUploadMediaTask 等任务使用)
111
+ if @git_root_path
112
+ begin
113
+ # 获取当前 HEAD commit 信息
114
+ git_commit_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: @git_root_path)
115
+ if git_commit_info
116
+ param[:git_commit_id] = git_commit_info[:commit_id]
117
+ param[:git_commit_time] = git_commit_info[:commit_time]
118
+ param[:git_commit_desc] = git_commit_info[:commit_desc]
119
+ end
120
+ rescue => e
121
+ # 如果获取失败,不影响主流程
122
+ Funlog.instance.fancyinfo_warning("获取 git commit 信息失败: #{e.message}") if ENV['PINDO_DEBUG']
123
+ end
124
+ end
125
+
126
+ param
127
+ end
79
128
  end
80
129
  end
81
130
  end
@@ -210,16 +210,19 @@ module Pindo
210
210
 
211
211
  # 从依赖任务获取或自动获取 git commit 信息
212
212
  def fetch_git_commit_info
213
- # 1. 首先尝试从 GitCommitTask 依赖任务获取
214
- git_commit_data = get_data_param_by_key(:git_commit)
215
- if git_commit_data && git_commit_data[:task_param]
216
- param = git_commit_data[:task_param]
213
+ # 1. 优先从 GitTagTask 依赖任务获取(打 tag 后的 commit 信息更准确)
214
+ git_data = get_data_param_by_key(:git_tag)
215
+ # 2. 降级到 GitCommitTask
216
+ git_data = get_data_param_by_key(:git_commit) if git_data.nil? || git_data.empty?
217
+
218
+ if git_data && git_data[:task_param]
219
+ param = git_data[:task_param]
217
220
  @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
218
221
  @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
219
222
  @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
220
223
  end
221
224
 
222
- # 2. 如果依赖任务没有提供,且指定了 project_dir,使用自动获取
225
+ # 3. 如果依赖任务都没有提供,且指定了 project_dir,使用自动获取
223
226
  if (@git_commit_id.nil? || @git_commit_id.empty?) && @project_dir
224
227
  # 查找 git 仓库根目录
225
228
  git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: @project_dir)
@@ -97,17 +97,20 @@ module Pindo
97
97
 
98
98
  # 2. 如果没有提供 git_commit_id,尝试从依赖任务获取或自动获取
99
99
  if @git_commit_id.nil? || @git_commit_id.empty?
100
- # 2.1 首先尝试从 GitCommitTask 依赖任务获取
101
- git_commit_data = get_data_param_by_key(:git_commit)
102
- if git_commit_data && git_commit_data[:task_param]
103
- param = git_commit_data[:task_param]
100
+ # 2.1 优先从 GitTagTask 依赖任务获取(打 tag 后的 commit 信息更准确)
101
+ git_data = get_data_param_by_key(:git_tag)
102
+ # 2.2 降级到 GitCommitTask
103
+ git_data = get_data_param_by_key(:git_commit) if git_data.nil? || git_data.empty?
104
+
105
+ if git_data && git_data[:task_param]
106
+ param = git_data[:task_param]
104
107
  # 尝试从 task_param 获取 commit 信息
105
108
  @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
106
109
  @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
107
110
  @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
108
111
  end
109
112
 
110
- # 2.2 如果依赖任务没有提供,使用 get_latest_conventional_commit
113
+ # 2.3 如果依赖任务都没有提供,使用 get_latest_conventional_commit
111
114
  if @git_commit_id.nil? || @git_commit_id.empty?
112
115
  git_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: git_root)
113
116
  @git_commit_id = git_info[:commit_id]
@@ -93,11 +93,15 @@ module Pindo
93
93
 
94
94
  # 从依赖任务获取数据
95
95
  def fetch_data_from_dependencies
96
- # 1. 从 GitCommitTask 获取 commit 信息
96
+ # 1. 获取 commit 信息(优先从 GitTagTask,降级到 GitCommitTask)
97
97
  if @git_commit_id.nil?
98
- git_commit_data = get_data_param_by_key(:git_commit)
99
- if git_commit_data && git_commit_data[:task_param]
100
- param = git_commit_data[:task_param]
98
+ # 1.1 优先从 GitTagTask 依赖任务获取(打 tag 后的 commit 信息更准确)
99
+ git_data = get_data_param_by_key(:git_tag)
100
+ # 1.2 降级到 GitCommitTask
101
+ git_data = get_data_param_by_key(:git_commit) if git_data.nil? || git_data.empty?
102
+
103
+ if git_data && git_data[:task_param]
104
+ param = git_data[:task_param]
101
105
  @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
102
106
  @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
103
107
  @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.14.7"
9
+ VERSION = "5.14.8"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.7
4
+ version: 5.14.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-12-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: claide
@@ -95,20 +95,14 @@ dependencies:
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 0.1.0
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: 0.1.9
98
+ version: 0.3.0
102
99
  type: :runtime
103
100
  prerelease: false
104
101
  version_requirements: !ruby/object:Gem::Requirement
105
102
  requirements:
106
103
  - - "~>"
107
104
  - !ruby/object:Gem::Version
108
- version: 0.1.0
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: 0.1.9
105
+ version: 0.3.0
112
106
  - !ruby/object:Gem::Dependency
113
107
  name: jpsclient
114
108
  requirement: !ruby/object:Gem::Requirement
@@ -507,7 +501,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
507
501
  - !ruby/object:Gem::Version
508
502
  version: 3.0.0
509
503
  requirements: []
510
- rubygems_version: 3.6.3
504
+ rubygems_version: 4.0.3
511
505
  specification_version: 4
512
506
  summary: easy work
513
507
  test_files: []