pindo 5.20.0 → 5.20.1

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.
@@ -1,5 +1,6 @@
1
1
  require 'pindo/module/task/model/git_task'
2
2
  require 'pindo/base/git_handler'
3
+ require 'pindo/module/source_files_guard'
3
4
  require 'pindo/module/utils/git_repo_helper'
4
5
 
5
6
  module Pindo
@@ -26,9 +27,9 @@ module Pindo
26
27
  # - tag_pre: tag前缀,默认 'v'
27
28
  # 注意:版本号从 GitCommitTask 获取(GitTagTask 必须依赖 GitCommitTask)
28
29
  def initialize(project_path, options = {})
29
- options[:project_path] = project_path
30
+ @process_type = options[:process_type]
30
31
  # 调用基类初始化(基类会设置所有通用属性)
31
- super("Git仓库打Tag", options)
32
+ super("Git仓库打Tag", options.merge(project_path: project_path))
32
33
  end
33
34
 
34
35
  def validate
@@ -57,19 +58,25 @@ module Pindo
57
58
  stash_saved = false
58
59
 
59
60
  begin
60
- # 1. 工作目录不干净则暂存
61
+ # 1. 先从 GitCommitTask 回填 process_type,再决定提交或 stash
62
+ backfill_params_from_commit_task(git_commit_data)
63
+
64
+ build_changes_committed = commit_build_changes? && commit_build_changes(root_dir)
65
+
66
+ # 未命中固定源码清单的构建产物不进入提交;暂存后再合并、打 tag。
61
67
  stash_saved = stash_if_dirty(root_dir, stash_name)
62
68
 
63
- # 2. 从 GitCommitTask 回填参数(须在合并之前,确保 release_branch 等正确)
64
- backfill_params_from_commit_task(git_commit_data)
69
+ if build_changes_committed
70
+ Pindo::GitHandler.check_unpushed_commits(project_dir: root_dir, branch: coding_branch)
71
+ end
65
72
 
66
- # 3. 合并到发布分支
73
+ # 2. 合并到发布分支
67
74
  merge_to_release_branch(root_dir, coding_branch)
68
75
 
69
- # 4. 解析版本号
76
+ # 3. 解析版本号
70
77
  resolve_build_version(root_dir, git_commit_data, git_repo_helper)
71
78
 
72
- # 5. 创建并推送 Tag
79
+ # 4. 创建并推送 Tag
73
80
  tag_name = "#{@tag_pre}#{@build_version}"
74
81
  git_repo_helper.create_and_push_tag(
75
82
  project_dir: root_dir,
@@ -77,7 +84,7 @@ module Pindo
77
84
  tag_type: @tag_type
78
85
  )
79
86
  ensure
80
- # 6. 还原 stash
87
+ # 5. 还原 stash
81
88
  restore_stash(root_dir, stash_name) if stash_saved
82
89
  end
83
90
  end
@@ -94,7 +101,7 @@ module Pindo
94
101
  true
95
102
  end
96
103
 
97
- # 从 GitCommitTask 回填 release_branch / tag_pre / tag_type / ver_inc
104
+ # 从 GitCommitTask 回填 Git 参数和未提交文件处理方式
98
105
  def backfill_params_from_commit_task(git_commit_data)
99
106
  return unless git_commit_data && git_commit_data[:task_param]
100
107
 
@@ -103,10 +110,59 @@ module Pindo
103
110
  @tag_pre = param[:tag_pre] if param[:tag_pre]
104
111
  @tag_type = param[:tag_type] if param[:tag_type]
105
112
  @ver_inc = param[:ver_inc] if param[:ver_inc]
113
+ @process_type = param[:process_type] if param[:process_type]
114
+ @build_version = param[:build_version] if param[:build_version]
115
+ @build_number = param[:build_number] if param[:build_number]
116
+ end
117
+
118
+ def commit_build_changes?
119
+ @process_type == Pindo::UncommittedFilesProcessType::COMMIT
120
+ end
121
+
122
+ # 只提交 autobuild 明确注入的源码文件,避免把 Pods、DerivedData 等构建产物带入发布提交。
123
+ def commit_build_changes(root_dir)
124
+ guard_paths = existing_guard_paths(
125
+ root_dir,
126
+ Pindo::BuildSourceFilesGuard.for_project(@project_path)
127
+ )
128
+ return false if guard_paths.empty?
129
+
130
+ Pindo::GitHandler.git!(git_command(root_dir, 'add', '--', *guard_paths))
131
+ staged_files = Pindo::GitHandler.git!(
132
+ git_command(root_dir, 'diff', '--cached', '--name-only', '--', *guard_paths)
133
+ ).lines.map(&:strip).reject(&:empty?)
134
+ return false if staged_files.empty?
135
+
136
+ commit_message = "chore(build): 更新版本至 #{@build_version}"
137
+ Pindo::GitHandler.git!(
138
+ git_command(root_dir, 'commit', '--only', '-m', commit_message, '--', *staged_files)
139
+ )
140
+ Funlog.instance.fancyinfo_success("已提交构建注入源码: #{staged_files.join(', ')}")
141
+ true
142
+ end
143
+
144
+ def existing_guard_paths(root_dir, source_files)
145
+ expanded_root = File.realpath(root_dir)
146
+ root_prefix = "#{expanded_root}#{File::SEPARATOR}"
147
+
148
+ Array(source_files).filter_map do |path|
149
+ next unless File.exist?(path)
150
+
151
+ expanded_path = File.realpath(path)
152
+ next unless expanded_path.start_with?(root_prefix)
153
+
154
+ expanded_path.delete_prefix(root_prefix)
155
+ end.uniq
156
+ end
157
+
158
+ def git_command(root_dir, command, *arguments)
159
+ ['--literal-pathspecs', '-C', root_dir, command, *arguments]
106
160
  end
107
161
 
108
162
  # 将编码分支双向合并到发布分支,确保两分支同步到同一节点
109
163
  def merge_to_release_branch(root_dir, coding_branch)
164
+ # 解析发布分支(独立运行、或未经 GitCommitTask 回填时也能得到正确分支)
165
+ @release_branch = Pindo::GitHandler.resolve_release_branch(local_repo_dir: root_dir, preferred: @release_branch)
110
166
  return if coding_branch == @release_branch
111
167
 
112
168
  Pindo::GitHandler.merge_branches(
@@ -141,6 +141,49 @@ module Pindo
141
141
  env_name: 'PINDO_JPS_INDEX',
142
142
  optional: true,
143
143
  example: 'pindo jps download --index=1'
144
+ ),
145
+
146
+ type: OptionItem.new(
147
+ key: :type,
148
+ name: '工作流类型',
149
+ description: '指定要配置的工作流类型,逗号分隔(ipa,apk,zip,mac,exe,git);不指定时弹出交互多选菜单',
150
+ type: String,
151
+ env_name: 'PINDO_JPS_CONFIG_TYPE',
152
+ optional: true,
153
+ cacheable: false,
154
+ example: 'pindo jps config --type=ipa,apk,git'
155
+ ),
156
+
157
+ clean: OptionItem.new(
158
+ key: :clean,
159
+ name: '清除配置',
160
+ description: '清除 JPSBuildConfig.json 中指定或选中的工作流绑定',
161
+ type: OptionItem::Boolean,
162
+ env_name: 'PINDO_JPS_CONFIG_CLEAN',
163
+ optional: true,
164
+ example: 'pindo jps config --clean'
165
+ ),
166
+
167
+ proj: OptionItem.new(
168
+ key: :proj,
169
+ name: 'JPS项目名',
170
+ description: '直接指定 JPS 上的项目名称,跳过项目选择菜单(非交互场景使用)',
171
+ type: String,
172
+ env_name: 'PINDO_JPS_PROJ',
173
+ optional: true,
174
+ cacheable: false,
175
+ example: 'pindo jps config --proj=MyApp --type=ipa'
176
+ ),
177
+
178
+ workflow_name: OptionItem.new(
179
+ key: :workflow_name,
180
+ name: '工作流名称',
181
+ description: '按名称指定工作流,用于某类型匹配到多个工作流时消歧(非交互场景使用)',
182
+ type: String,
183
+ env_name: 'PINDO_JPS_WORKFLOW_NAME',
184
+ optional: true,
185
+ cacheable: false,
186
+ example: 'pindo jps config --proj=MyApp --type=ipa --workflow_name="iOS IPA Upload"'
144
187
  )
145
188
  }
146
189
  end
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.20.0"
9
+ VERSION = "5.20.1"
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.20.0
4
+ version: 5.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
@@ -333,6 +333,7 @@ files:
333
333
  - lib/pindo/command/jps.rb
334
334
  - lib/pindo/command/jps/apptest.rb
335
335
  - lib/pindo/command/jps/bind.rb
336
+ - lib/pindo/command/jps/config.rb
336
337
  - lib/pindo/command/jps/download.rb
337
338
  - lib/pindo/command/jps/login.rb
338
339
  - lib/pindo/command/jps/media.rb
@@ -408,6 +409,7 @@ files:
408
409
  - lib/pindo/module/pgyer/pgyerhelper.rb
409
410
  - lib/pindo/module/resign/ipa_resign_adapter.rb
410
411
  - lib/pindo/module/resign/mac_app_resign_adapter.rb
412
+ - lib/pindo/module/source_files_guard.rb
411
413
  - lib/pindo/module/task/core/concurrent_execution_strategy.rb
412
414
  - lib/pindo/module/task/core/dependency_checker.rb
413
415
  - lib/pindo/module/task/core/execution_strategy.rb