pindo 5.12.1 → 5.12.2

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: 298ff00b838b7929bf82b9d0f1751afa68a7aa09cb00b3aa64991b807cb101f8
4
- data.tar.gz: 21ae02b4b9edc916262eb1a72ed417e7fd875454a6870af99bfb699d404f7783
3
+ metadata.gz: 6095e9d8ae3f34ca9e43e111344d3769c62e4d23b929ed2f8dcbab2288296107
4
+ data.tar.gz: 9c45c852836d6c9549d1625866fbee560dd38abb1b793401b80ff3c103e2f5a8
5
5
  SHA512:
6
- metadata.gz: ccc097a2e5400394bcdcb3dfffc44bb366ff590163af4643d6e5be910884127e15c589c94b5fe408844c7de4eeff4a9e3830c0303f1399e2a82076484122e5a9
7
- data.tar.gz: 342289896b13603e77226b8d6ef18a8c1549b8fe265050ba3f9e869b3c3f7e327f5623aa300b0dbdef526a39f839977cb55837d2fa209ab48e214937b7738e98
6
+ metadata.gz: 74666b706663478292b86f5caacd7c17846507ce8aef44b8b7481c73d84f89f9a766c425939c2b5954dc536b480e150d3fff174325683f2b44e5b5d067e8477d
7
+ data.tar.gz: ca31fa0a538fac32db28d7e657a04b0eb3c3304880e3dbb219c1787c26e4bf6f264e4b2e3181acb84378fdb48f4250a13bc6f719c3e30546ab848e271d090058
@@ -646,6 +646,22 @@ module Pindo
646
646
  new_tag
647
647
  end
648
648
 
649
+ # 检查仓库是否有未提交的更改(包括未暂存和已暂存的更改)
650
+ # @param git_root_dir [String] 项目目录路径
651
+ # @return [Boolean] 如果有未提交的更改返回true,否则返回false
652
+ def has_uncommitted_changes?(git_root_dir:nil)
653
+ return false if git_root_dir.nil?
654
+
655
+ begin
656
+ # 使用 git status --porcelain 检查是否有更改
657
+ # 如果输出不为空,说明有未提交的更改
658
+ status_output = git!(%W(-C #{git_root_dir} status --porcelain)).strip
659
+ !status_output.empty?
660
+ rescue StandardError => e
661
+ false
662
+ end
663
+ end
664
+
649
665
  # 检查tag是否在指定的commit上
650
666
  # @param git_root_dir [String] 项目目录路径
651
667
  # @param tag_name [String] 标签名称
@@ -109,13 +109,19 @@ module Pindo
109
109
  # 初始化三级结构(总是保存到内存,不管是否启用缓存)
110
110
  @memory_selections[project_path] ||= {}
111
111
  @memory_selections[project_path][root_command] ||= {}
112
- @memory_selections[project_path][root_command][key] = value
112
+
113
+ # 如果值为 nil,则删除该键而不是保存 nil
114
+ if value.nil?
115
+ @memory_selections[project_path][root_command].delete(key)
116
+ puts "[PindoContext] 从内存删除: [#{project_path}][#{root_command}][#{key}]" if verbose?
117
+ else
118
+ @memory_selections[project_path][root_command][key] = value
119
+ puts "[PindoContext] 保存到内存: [#{project_path}][#{root_command}][#{key}] = #{value.inspect}" if verbose?
120
+ end
113
121
 
114
122
  # 更新该命令组的最后修改时间
115
123
  @memory_selections[project_path][root_command]['__last_modified__'] = Time.now.to_i
116
124
 
117
- puts "[PindoContext] 保存到内存: [#{project_path}][#{root_command}][#{key}] = #{value.inspect}" if verbose?
118
-
119
125
  # 仅在启用缓存时保存到文件
120
126
  if @cache_enabled
121
127
  save_file_cache
@@ -306,6 +312,8 @@ module Pindo
306
312
  commands.each do |command, selections|
307
313
  file_cache[project_path][command] ||= {}
308
314
  selections.each do |key, value|
315
+ # 跳过 nil 值,不保存到文件
316
+ next if value.nil?
309
317
  # 将符号键转换为字符串
310
318
  string_key = key.to_s
311
319
  file_cache[project_path][command][string_key] = value
@@ -503,8 +511,9 @@ module Pindo
503
511
  puts "────────────────────────────────────────"
504
512
 
505
513
  cached_selections.each do |key, value|
506
- # 跳过内部字段
514
+ # 跳过内部字段和 nil 值
507
515
  next if key.to_s.start_with?('__')
516
+ next if value.nil?
508
517
 
509
518
  case key.to_s
510
519
  when 'bundle_id'
@@ -142,13 +142,9 @@ module Pindo
142
142
 
143
143
  tasks = []
144
144
 
145
- # 1. Git 标签任务(如果需要上传)
146
- if @args_upload_flag
147
- git_tag_task = Pindo::TaskSystem::GitTagTask.new(
148
- config[:project_path]
149
- )
150
- tasks << git_tag_task
151
- end
145
+ # 1. Git 标签任务(所有编译场景都需要打 Tag)
146
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(config[:project_path])
147
+ tasks << git_tag_task
152
148
 
153
149
  # 2. Unity 导出任务(仅 Unity 工程)
154
150
  if is_unity
@@ -166,7 +162,7 @@ module Pindo
166
162
  export_path: android_export_path,
167
163
  context: unity_context
168
164
  )
169
- unity_task.dependencies << tasks.first.id if tasks.any?
165
+ unity_task.dependencies << git_tag_task.id
170
166
  tasks << unity_task
171
167
  end
172
168
 
@@ -140,11 +140,9 @@ module Pindo
140
140
 
141
141
  tasks = []
142
142
 
143
- # 1. Git 标签任务(如果需要上传)
144
- if @args_upload_flag
145
- git_tag_task = Pindo::TaskSystem::GitTagTask.new(config[:project_path])
146
- tasks << git_tag_task
147
- end
143
+ # 1. Git 标签任务(所有编译场景都需要打 Tag)
144
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(config[:project_path])
145
+ tasks << git_tag_task
148
146
 
149
147
  # 2. Unity 导出任务(仅 Unity 工程)
150
148
  if is_unity
@@ -162,7 +160,7 @@ module Pindo
162
160
  export_path: ios_export_path,
163
161
  context: unity_context
164
162
  )
165
- unity_task.dependencies << tasks.first.id if tasks.any?
163
+ unity_task.dependencies << git_tag_task.id
166
164
  tasks << unity_task
167
165
  end
168
166
 
@@ -7,6 +7,7 @@ require 'pindo/module/build/git_repo_helper'
7
7
  require 'pindo/module/build/build_helper'
8
8
  require 'pindo/module/task/task_manager'
9
9
  require 'pindo/module/task/model/upload_task'
10
+ require 'pindo/module/task/model/git_tag_task'
10
11
 
11
12
  module Pindo
12
13
  class Command
@@ -141,21 +142,15 @@ module Pindo
141
142
  tasks = []
142
143
 
143
144
  # 1. Git Tag 任务(检查并添加标签)
144
- git_repo_helper = Pindo::GitRepoHelper.share_instance
145
- Dir.chdir(project_dir)
146
- is_need_add_tag, tag_action_parms = git_repo_helper.check_is_need_add_tag?(project_dir)
147
- if is_need_add_tag
148
- git_repo_helper.create_and_push_tag(
149
- project_dir: project_dir,
150
- mode: 'minor',
151
- force_retag: tag_action_parms&.include?('--retag') || false,
152
- custom_tag: nil,
153
- release_branch: 'master'
154
- )
155
- end
145
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(project_dir)
146
+ tasks << git_tag_task
156
147
 
157
148
  # 2. 查找并创建上传任务
158
149
  upload_tasks = find_and_create_upload_tasks(project_dir)
150
+ # 让所有上传任务依赖 Git Tag 任务
151
+ upload_tasks.each do |upload_task|
152
+ upload_task.dependencies << git_tag_task.id
153
+ end
159
154
  tasks.concat(upload_tasks)
160
155
 
161
156
  tasks
@@ -11,6 +11,7 @@ require 'pindo/module/task/task_manager'
11
11
  require 'pindo/module/task/model/build_task'
12
12
  require 'pindo/module/task/model/unity_export_task'
13
13
  require 'pindo/module/task/model/upload_task'
14
+ require 'pindo/module/task/model/git_tag_task'
14
15
 
15
16
  module Pindo
16
17
  class Command
@@ -56,7 +57,7 @@ module Pindo
56
57
  $ pindo unity autobuild --upload # 编译所有类型并上传到JPS
57
58
 
58
59
  $ pindo unity autobuild --proj="My App" # 指定项目名称
59
- DESC
60
+ DESC
60
61
 
61
62
  # 命令参数
62
63
  self.arguments = [
@@ -139,27 +140,13 @@ DESC
139
140
  raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
140
141
  end
141
142
 
142
- if @args_upload_flag
143
- git_repo_helper = Pindo::GitRepoHelper.share_instance
144
- is_need_add_tag, tag_action_parms = git_repo_helper.check_is_need_add_tag?(pindo_project_dir)
145
- if is_need_add_tag
146
- git_repo_helper.create_and_push_tag(
147
- project_dir: pindo_project_dir,
148
- mode: 'minor',
149
- force_retag: tag_action_parms&.include?('--retag') || false,
150
- custom_tag: nil,
151
- release_branch: 'master'
152
- )
153
- end
154
- end
155
-
156
143
  # 1. 获取要构建的类型列表
157
144
  selected_platforms = get_selected_build_types()
158
145
 
159
146
  # 2. 按平台顺序准备所有配置(iOS → Android → Web)
160
147
  all_platform_configs = prepare_all_platform_configs(selected_platforms)
161
148
 
162
- # 3. 按平台顺序创建所有任务
149
+ # 3. 按平台顺序创建所有任务(包含 GitTagTask)
163
150
  all_tasks = make_task_with_config(selected_platforms, all_platform_configs)
164
151
 
165
152
  # 4. 统一添加到任务管理器并执行
@@ -178,38 +165,33 @@ DESC
178
165
  # 按平台顺序创建所有任务
179
166
  def make_task_with_config(selected_platforms, all_platform_configs)
180
167
  all_tasks = []
181
- build_tasks = [] # 收集所有构建任务
168
+ platform_build_tasks = {} # 存储平台对应的构建任务
169
+
170
+ # 第零步:创建 Git 标签任务(所有编译场景都需要打 Tag)
171
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(Dir.pwd)
172
+ all_tasks << git_tag_task
182
173
 
183
- # 第一步:创建所有导出和构建任务
174
+ # 第一步:为每个平台创建导出和构建任务
184
175
  selected_platforms.each do |platform|
185
176
  platform_config = all_platform_configs[platform]
186
177
 
187
- # 1. 创建 Unity 导出任务
178
+ # 1. 创建 Unity 导出任务(依赖 Git 标签任务)
188
179
  unity_task = create_unity_export_task(platform, all_platform_configs)
180
+ unity_task.dependencies << git_tag_task.id
189
181
  all_tasks << unity_task
190
182
 
191
- # 2. 创建构建任务
183
+ # 2. 创建构建任务(依赖导出任务)
192
184
  build_task = create_build_task(platform, platform_config, all_platform_configs, unity_task)
193
185
  all_tasks << build_task
194
- build_tasks << build_task # 收集构建任务
186
+ platform_build_tasks[platform] = build_task
195
187
  end
196
188
 
197
- # 第二步:创建所有上传任务(如果需要)
189
+ # 第二步:创建所有上传任务(最后添加,只依赖对应平台的构建任务)
190
+ # 注意:create_upload_task 内部已设置 dependencies: [build_task.id]
198
191
  if @args_upload_flag
199
- selected_platforms.each_with_index do |platform, index|
200
- # 获取对应平台的构建任务
201
- platform_build_task = build_tasks[index]
202
-
203
- # 创建上传任务
204
- upload_task = create_upload_task(platform, all_platform_configs, platform_build_task)
205
-
206
- # 让上传任务依赖所有构建任务完成
207
- build_tasks.each do |build_task|
208
- unless upload_task.dependencies.include?(build_task.id)
209
- upload_task.dependencies << build_task.id
210
- end
211
- end
212
-
192
+ selected_platforms.each do |platform|
193
+ build_task = platform_build_tasks[platform]
194
+ upload_task = create_upload_task(platform, all_platform_configs, build_task)
213
195
  all_tasks << upload_task
214
196
  end
215
197
  end
@@ -28,15 +28,13 @@ module Pindo
28
28
 
29
29
  # 1. 验证 Git 仓库
30
30
  unless is_git_directory?(local_repo_dir: project_dir)
31
- Funlog.instance.fancyinfo_error("当前目录不是git仓库,请在git仓库目录下执行此命令")
32
- return
31
+ raise Informative, "当前目录不是git仓库,请在git仓库目录下执行此命令"
33
32
  end
34
33
 
35
34
  # 获取git仓库根目录
36
35
  root_dir = git_root_directory(local_repo_dir: project_dir)
37
36
  if root_dir.nil?
38
- Funlog.instance.fancyinfo_error("无法获取git仓库根目录")
39
- return
37
+ raise Informative, "无法获取git仓库根目录"
40
38
  end
41
39
 
42
40
  # 2. 处理未提交的文件
@@ -54,13 +52,15 @@ module Pindo
54
52
  coding_branch: coding_branch
55
53
  )
56
54
 
57
- # 5. 添加版本标签
58
- add_release_tag(
55
+ # 5. 添加版本标签并返回 tag 名称
56
+ new_tag = add_release_tag(
59
57
  project_dir: root_dir,
60
58
  increment_mode: mode,
61
59
  force_retag: force_retag,
62
60
  custom_tag: custom_tag
63
61
  )
62
+
63
+ new_tag
64
64
  end
65
65
 
66
66
  # 检查并安装 git-cliff
@@ -192,7 +192,17 @@ module Pindo
192
192
  current_git_root_path = git_root_directory(local_repo_dir: project_path)
193
193
  latest_tag = get_latest_version_tag(project_dir: current_git_root_path)
194
194
 
195
- unless is_tag_at_head?(git_root_dir: current_git_root_path, tag_name: latest_tag)
195
+ # 检查是否需要打 tag:
196
+ # 1. 最新 tag 不在 HEAD 上,或者
197
+ # 2. 仓库有未提交的更改
198
+ tag_not_at_head = !is_tag_at_head?(git_root_dir: current_git_root_path, tag_name: latest_tag)
199
+ has_uncommitted = has_uncommitted_changes?(git_root_dir: current_git_root_path)
200
+
201
+ if tag_not_at_head || has_uncommitted
202
+ # 提示用户需要打 tag 的原因
203
+ if has_uncommitted && !tag_not_at_head
204
+ puts "\n注意:仓库有未提交的更改,建议提交后再打 Tag"
205
+ end
196
206
  # 检查环境变量
197
207
  env_tag_decision = ENV['PINDO_TAG_DECISION']
198
208
  if env_tag_decision && !env_tag_decision.empty?
@@ -340,9 +350,8 @@ module Pindo
340
350
  # 清除临时缓存
341
351
  self.temp_tag_decision = nil
342
352
  else
343
- # 清空持久化缓存
344
- context.set_selection(PindoContext::SelectionKey::TAG_DECISION, nil)
345
- # 保存到临时缓存(仅在内存中,不会写入文件)
353
+ # 不清空持久化缓存(避免将 nil 写入文件)
354
+ # 只使用临时缓存(仅在内存中,不会写入文件)
346
355
  self.temp_tag_decision = {
347
356
  action: selected_action,
348
357
  description: selected_description,
@@ -385,7 +394,7 @@ module Pindo
385
394
  else
386
395
  Funlog.instance.fancyinfo_success("tag #{new_tag} 已存在")
387
396
  Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
388
- return
397
+ return new_tag # 返回已存在的 tag
389
398
  end
390
399
  end
391
400
 
@@ -395,7 +404,7 @@ module Pindo
395
404
 
396
405
  Funlog.instance.fancyinfo_success("创建tag: #{new_tag}")
397
406
  Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
398
- return
407
+ return new_tag # 返回新创建的 tag
399
408
  end
400
409
 
401
410
  # 原有的自动递增逻辑
@@ -410,13 +419,13 @@ module Pindo
410
419
  )
411
420
  Funlog.instance.fancyinfo_success("创建初始tag: #{new_tag}")
412
421
  Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
413
- return
422
+ return new_tag # 返回初始 tag
414
423
  end
415
424
 
416
425
  if is_tag_at_head?(git_root_dir: project_dir, tag_name: latest_tag)
417
426
  Funlog.instance.fancyinfo_success("当前commit已有tag: #{latest_tag},无需重新打tag")
418
427
  Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
419
- return
428
+ return latest_tag # 返回已存在的 tag
420
429
  end
421
430
 
422
431
  Funlog.instance.fancyinfo_success("最近的上次tag是: #{latest_tag} ")
@@ -429,6 +438,8 @@ module Pindo
429
438
 
430
439
  Funlog.instance.fancyinfo_success("当前仓库的tag: #{new_tag}")
431
440
  Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
441
+
442
+ new_tag # 返回新创建的 tag
432
443
  end
433
444
 
434
445
  # 合并到发布分支
@@ -18,7 +18,7 @@ module Pindo
18
18
  end
19
19
 
20
20
  def self.default_retry_count
21
- 2 # 可以重试 2
21
+ 0 # 可以重试 0
22
22
  end
23
23
 
24
24
  def self.default_retry_delay
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.12.1"
9
+ VERSION = "5.12.2"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.12.1
4
+ version: 5.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade