pindo 5.18.5 → 5.18.9

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/command/android/autobuild.rb +16 -3
  3. data/lib/pindo/command/appstore/adhocbuild.rb +1 -1
  4. data/lib/pindo/command/ios/autobuild.rb +1 -1
  5. data/lib/pindo/command/jps/upload.rb +1 -1
  6. data/lib/pindo/command/unity/autobuild.rb +2 -2
  7. data/lib/pindo/command/utils/gitconfig.rb +268 -0
  8. data/lib/pindo/command/utils/repoinit.rb +32 -15
  9. data/lib/pindo/command/utils/tag.rb +1 -1
  10. data/lib/pindo/command/utils.rb +1 -0
  11. data/lib/pindo/module/android/android_build_helper.rb +109 -69
  12. data/lib/pindo/module/android/android_config_helper.rb +1 -1
  13. data/lib/pindo/module/android/android_project_helper.rb +88 -0
  14. data/lib/pindo/module/android/gradle_helper.rb +27 -2
  15. data/lib/pindo/module/android/keystore_helper.rb +99 -30
  16. data/lib/pindo/module/android/workflow_gradle_injector.rb +82 -6
  17. data/lib/pindo/module/pgyer/pgyerhelper.rb +6 -14
  18. data/lib/pindo/module/task/model/build/android_build_dev_task.rb +1 -1
  19. data/lib/pindo/module/task/model/build/ios_build_adhoc_task.rb +3 -3
  20. data/lib/pindo/module/task/model/build/ios_build_appstore_task.rb +3 -4
  21. data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +1 -2
  22. data/lib/pindo/module/task/model/git/git_commit_task.rb +6 -6
  23. data/lib/pindo/module/task/model/git/git_tag_task.rb +1 -1
  24. data/lib/pindo/module/task/model/git_task.rb +1 -1
  25. data/lib/pindo/module/task/model/unity/unity_export_task.rb +14 -0
  26. data/lib/pindo/module/utils/git_hook_helper.rb +654 -0
  27. data/lib/pindo/module/{build → utils}/git_repo_helper.rb +1 -1
  28. data/lib/pindo/module/xcode/xcode_build_config.rb +15 -3
  29. data/lib/pindo/options/groups/build_options.rb +0 -33
  30. data/lib/pindo/options/groups/utils_options.rb +11 -0
  31. data/lib/pindo/version.rb +2 -2
  32. metadata +10 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5570599c0e84edb77c22267e890c57f736800bc046581d7a902e28b4b5c33f
4
- data.tar.gz: 46b689df14719e8a7b0ef3af23e209d9e70484b3915b45a02c8c014ab1d2ddb3
3
+ metadata.gz: d3b74ddb66022968993f331b407f3a50a41d94a827e15e75f75dac1b8d5aadc1
4
+ data.tar.gz: '08c5e2e855359f4369e02cb6cab841d38e3344794a7d4e8f9b0f2695683d1da2'
5
5
  SHA512:
6
- metadata.gz: c2e5bb57d0a922210eff69f20fc7aabdf42660f01073e2a56378f32ff2380173eedd37b00e54f368051566903ac95c37f7139b17760c19c17ce889422e7078a8
7
- data.tar.gz: 84d21199d7e08ad161a286090fbbc40c0a421f021f654dfde9b663fffc2c0921927e6a95a7cc0db21b074a1a4af0dcd28e354183bcf4bd5bb318dc178cf0a37b
6
+ metadata.gz: 6c1c36ddcf83fcff151bdd21e8e3104eec862b5c72aa15303a8fe3cae4f9be0dd36f37e2cee24d293e6ace76f895c72f057a18f12485c6d4a08905bb49350e21
7
+ data.tar.gz: 1f3a484ff340bd398d150960753bb541103aca2b5a8ba30e712733c029e209c9fdfcb7db6c2d80b7c1bb1e1c8202d3319600ab12d23c4cb928c3f55c2390e74c
@@ -2,7 +2,7 @@ require 'highline/import'
2
2
  require 'fileutils'
3
3
  require 'pindo/base/executable'
4
4
  require 'pindo/module/build/build_helper'
5
- require 'pindo/module/build/git_repo_helper'
5
+ require 'pindo/module/utils/git_repo_helper'
6
6
  require 'pindo/module/android/android_build_helper'
7
7
  require 'pindo/module/android/android_config_helper'
8
8
  require 'pindo/module/task/task_manager'
@@ -96,7 +96,7 @@ module Pindo
96
96
  # 定义此命令使用的参数项
97
97
  def self.option_items
98
98
  @option_items ||= Pindo::Options::OptionGroup.merge(
99
- Pindo::Options::BuildOptions.select(:bundle_name, :release, :skipclean, :skipvalidate, :injectsigning),
99
+ Pindo::Options::BuildOptions.select(:bundle_name, :release),
100
100
  Pindo::Options::JPSOptions.select(:conf, :upload, :media, :bind, :send),
101
101
  Pindo::Options::UnityOptions.select(:skiplib, :skipyoo),
102
102
  Pindo::Options::UnityOptions.select_with_defaults(skipmacro: true),
@@ -147,7 +147,7 @@ module Pindo
147
147
  end
148
148
 
149
149
  def run
150
- pindo_project_dir = Dir.pwd
150
+ pindo_project_dir = safe_pwd!
151
151
 
152
152
  begin
153
153
  # 加载 JPS 配置(缓存 project_name,并通过映射表解析 bundle_id)
@@ -182,6 +182,19 @@ module Pindo
182
182
 
183
183
  private
184
184
 
185
+ # 有些场景下(例如用户删除了当前所在目录、或 shell 的 cwd 已失效),Dir.pwd 会抛 Errno::ENOENT。
186
+ # 这里做一次兜底:尝试切换到 ENV["PWD"](若可用),否则回退到 HOME,确保命令可继续执行并给出更可理解的行为。
187
+ def safe_pwd!
188
+ Dir.pwd
189
+ rescue Errno::ENOENT
190
+ fallback = ENV["PWD"]
191
+ fallback = nil unless fallback && File.directory?(fallback)
192
+ fallback ||= Dir.home
193
+
194
+ Dir.chdir(fallback)
195
+ Dir.pwd
196
+ end
197
+
185
198
  # 解析 bundle_name(优先级:命令行参数 > JPSBuildConfig映射 > prepare_upload交互选择)
186
199
  def resolve_bundle_name!
187
200
  # 优先级 1:命令行 --bundle_name 参数
@@ -4,7 +4,7 @@ require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/build/build_helper'
7
- require 'pindo/module/build/git_repo_helper'
7
+ require 'pindo/module/utils/git_repo_helper'
8
8
  require 'pindo/module/xcode/xcode_build_config'
9
9
  require 'pindo/module/xcode/xcode_build_helper'
10
10
  require 'pindo/config/ios_config_parser'
@@ -4,7 +4,7 @@ require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/build/build_helper'
7
- require 'pindo/module/build/git_repo_helper'
7
+ require 'pindo/module/utils/git_repo_helper'
8
8
  require 'pindo/module/xcode/xcode_build_config'
9
9
  require 'pindo/module/xcode/xcode_build_helper'
10
10
  require 'pindo/module/task/task_manager'
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
  require 'json'
4
4
  require 'faraday'
5
5
  require 'pindo/module/pgyer/pgyerhelper'
6
- require 'pindo/module/build/git_repo_helper'
6
+ require 'pindo/module/utils/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/jps/jps_upload_task'
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/unity/unity_helper'
7
7
  require 'pindo/module/build/build_helper'
8
- require 'pindo/module/build/git_repo_helper'
8
+ require 'pindo/module/utils/git_repo_helper'
9
9
  require 'pindo/module/task/pindo_task'
10
10
  require 'pindo/module/task/task_manager'
11
11
  require 'pindo/module/task/model/build_task'
@@ -101,7 +101,7 @@ module Pindo
101
101
  # 定义此命令使用的参数项
102
102
  def self.option_items
103
103
  @option_items ||= Pindo::Options::OptionGroup.merge(
104
- Pindo::Options::BuildOptions.select(:bundleid, :bundle_name, :types, :release, :adhoc, :skipclean, :skipvalidate, :injectsigning),
104
+ Pindo::Options::BuildOptions.select(:bundleid, :bundle_name, :types, :release, :adhoc),
105
105
  Pindo::Options::JPSOptions.select(:conf, :upload, :send, :media, :bind),
106
106
  Pindo::Options::UnityOptions.select(:skiplib, :skipyoo, :kill_unity),
107
107
  Pindo::Options::UnityOptions.select_with_defaults(skipmacro: true),
@@ -0,0 +1,268 @@
1
+ require 'fileutils'
2
+ require 'highline'
3
+ require 'pindo/base/git_handler'
4
+ require 'pindo/module/utils/git_hook_helper'
5
+
6
+ module Pindo
7
+ class Command
8
+ class Utils < Command
9
+ class Gitconfig < Utils
10
+
11
+ self.summary = '设置 pindo 全局 Git 配置与 commit 变更统计 hook'
12
+
13
+ self.description = <<-DESC
14
+ 一次性配置本机全局 Git 环境,使所有 Git 仓库共享同一套 pindo 约定。
15
+
16
+ 支持功能:
17
+
18
+ * 设置 Git 用户身份 (交互式):
19
+ - user.name 要求与飞书账号用户名一致,便于团队识别提交人
20
+ - user.email 要求与注册 gitee.com 等代码仓库的邮箱一致
21
+ - 已设置的值会显示当前值并询问是否修改,默认保留
22
+
23
+ * 设置全局 Git 配置:
24
+ - 禁止大小写: core.ignorecase = false
25
+ - 禁止自动 rebase: pull.rebase = false
26
+ - git 缓存内存大小: http.postBuffer = 157286400
27
+
28
+ * 自动安装并配置 git-lfs:
29
+ - 未检测到时通过 Homebrew 自动安装
30
+ - 运行 git lfs install --skip-repo 写全局 filter 配置
31
+ - 通过全局 hook (pre-push / post-checkout / post-commit /
32
+ post-merge) 让 git-lfs 全局生效,无需逐仓库 git lfs install
33
+ - 已知行为: 若仓库本地已有 git lfs install 生成的同名 hook,
34
+ LFS 会被调用两次(LFS 幂等无副作用,但 pre-push 会多一次
35
+ LFS 对象检查耗时; 这是为了保证自定义 hybrid hook 不被吞的
36
+ 主动权衡)
37
+
38
+ * 安装全局 commit 变更统计 hook (通过 core.hooksPath):
39
+ - 目标目录: 自适应已有 core.hooksPath,默认 ~/.git-hooks/
40
+ - prepare-commit-msg: 完全接管,自动追加变更统计
41
+ - 27 个转发桩: 4 个 LFS-aware + 23 个纯转发(尊重 foreign 文件)
42
+
43
+ 使用示例:
44
+
45
+ $ pindo utils gitconfig
46
+
47
+ 撤销方式:
48
+
49
+ $ git config --global --unset core.hooksPath
50
+ $ git config --global --unset core.ignorecase
51
+ $ git config --global --unset pull.rebase
52
+ $ git config --global --unset http.postBuffer
53
+ $ git lfs uninstall --skip-repo
54
+ $ rm -rf ~/.git-hooks
55
+ DESC
56
+
57
+ self.arguments = []
58
+
59
+ # 需要统一设置的全局 Git 配置(按团队约定)
60
+ # value: 目标值 / desc: 中文含义(用于日志输出)
61
+ GLOBAL_CONFIGS = {
62
+ 'core.ignorecase' => { value: 'false', desc: '禁止大小写' },
63
+ 'pull.rebase' => { value: 'false', desc: '禁止自动rebase' },
64
+ 'http.postBuffer' => { value: '157286400', desc: 'git缓存内存大小' },
65
+ }.freeze
66
+
67
+ def run
68
+ # --verbose 通过 ENV 向下传递到 GitHookHelper(helper 没有 CLAide 上下文)
69
+ ENV['PINDO_DEBUG'] ||= '1' if pindo_verbose?
70
+
71
+ if pindo_verbose?
72
+ puts ""
73
+ puts "==> pindo utils gitconfig:配置本机全局 Git 环境"
74
+ puts " 共 5 个步骤:用户身份 → Git 配置 → git-lfs 安装 → LFS filter → 全局 hook"
75
+ end
76
+
77
+ # 汇总 5 项全局 Git 配置,step [1/5] 和 [2/5] 处理完后统一打印
78
+ @final_configs = []
79
+
80
+ step_header(1, "设置 Git 用户身份 (user.name / user.email)")
81
+ setup_git_user_identity
82
+
83
+ step_header(2, "设置全局 Git 配置")
84
+ apply_global_git_configs
85
+
86
+ print_global_configs_summary
87
+
88
+ step_header(3, "检查并安装 git-lfs")
89
+ ensure_git_lfs_installed
90
+
91
+ step_header(4, "配置 git-lfs 全局 filter")
92
+ setup_git_lfs_filters
93
+
94
+ step_header(5, "安装全局 Git hook")
95
+ Pindo::GitHookHelper.share_instance.install_global_commit_stats_hook
96
+
97
+ puts "" if pindo_verbose?
98
+ Funlog.instance.fancyinfo_success("pindo utils gitconfig 全部完成 ✓")
99
+ end
100
+
101
+ private
102
+
103
+ # 打印 [1/5] + [2/5] 共 5 项全局 Git 配置的汇总
104
+ def print_global_configs_summary
105
+ puts ""
106
+ Funlog.instance.fancyinfo_start("全局 Git 配置汇总 (#{@final_configs.size} 项):")
107
+ @final_configs.each do |cfg|
108
+ line = " #{cfg[:desc]}:#{cfg[:key]} = #{cfg[:value]}"
109
+ line += "(#{cfg[:note]})" if cfg[:note]
110
+ if cfg[:status] == :updated
111
+ Funlog.instance.fancyinfo_update(line)
112
+ else
113
+ Funlog.instance.fancyinfo_success(line)
114
+ end
115
+ end
116
+ puts ""
117
+ end
118
+
119
+ # verbose 模式:--verbose 或 PINDO_DEBUG 环境变量
120
+ # 用 pindo_ 前缀避免与 CLAide 内部 verbose? 的方法可见性冲突
121
+ def pindo_verbose?
122
+ @verbose || !ENV['PINDO_DEBUG'].to_s.empty?
123
+ end
124
+
125
+ def step_header(n, title)
126
+ return unless pindo_verbose?
127
+ puts ""
128
+ puts "[#{n}/5] #{title}"
129
+ end
130
+
131
+ def vstart(msg)
132
+ Funlog.instance.fancyinfo_start(msg) if pindo_verbose?
133
+ end
134
+
135
+ # 检测 git-lfs 是否已安装,未安装时通过 Homebrew 自动安装
136
+ def ensure_git_lfs_installed
137
+ vstart("检查 git-lfs 安装状态...")
138
+ if system('command -v git-lfs > /dev/null 2>&1')
139
+ lfs_version = `git-lfs version 2>/dev/null`.strip
140
+ Funlog.instance.fancyinfo_success("git-lfs 已安装 (#{lfs_version})")
141
+ return
142
+ end
143
+
144
+ Funlog.instance.fancyinfo_warning("未检测到 git-lfs,准备通过 Homebrew 自动安装")
145
+ unless system('command -v brew > /dev/null 2>&1')
146
+ Funlog.instance.fancyinfo_error("Homebrew 未安装,无法自动安装 git-lfs")
147
+ Funlog.instance.fancyinfo_error("请手动安装 git-lfs 后重试: https://git-lfs.com/")
148
+ raise Informative, "git-lfs not installed and brew unavailable"
149
+ end
150
+
151
+ # 显式关闭 brew auto-update + env hints
152
+ # auto-update 会触发 brew 仓库的 git fetch,在无交互式凭据的环境下
153
+ # (例如 CI、GIT_TERMINAL_PROMPT=0)会卡死或报错,与本次安装无关
154
+ brew_env = {
155
+ 'HOMEBREW_NO_AUTO_UPDATE' => '1',
156
+ 'HOMEBREW_NO_ENV_HINTS' => '1',
157
+ }
158
+ vstart("执行: HOMEBREW_NO_AUTO_UPDATE=1 brew install git-lfs")
159
+ unless system(brew_env, 'brew', 'install', 'git-lfs')
160
+ Funlog.instance.fancyinfo_error("brew install git-lfs 失败")
161
+ Funlog.instance.fancyinfo_error("请手动执行以上命令排查后重试")
162
+ raise Informative, "brew install git-lfs failed"
163
+ end
164
+ Funlog.instance.fancyinfo_success("git-lfs 已安装")
165
+ end
166
+
167
+ # 设置 git-lfs 全局 filter 配置(写入 ~/.gitconfig,不触碰任何仓库的 .git/hooks/)
168
+ def setup_git_lfs_filters
169
+ vstart("执行: git lfs install --skip-repo(写入 ~/.gitconfig 的 filter.lfs.* 配置)")
170
+ Pindo::GitHandler.git!(%w(lfs install --skip-repo))
171
+ Funlog.instance.fancyinfo_success("git-lfs filter 已配置")
172
+ end
173
+
174
+ # 交互式设置 Git 用户身份 (user.name / user.email)
175
+ # - 已设置 → 显示当前值,询问是否修改(默认 N)
176
+ # - 未设置 → 强制提示,并明确告知命名要求
177
+ def setup_git_user_identity
178
+ ensure_git_user_field(
179
+ key: 'user.name',
180
+ label: 'Git 提交用户名',
181
+ hint: '请确保与飞书账号的用户名保持一致(便于团队识别提交人)',
182
+ prompt: '请输入 Git 提交用户名',
183
+ validator: ->(v) { !v.strip.empty? },
184
+ error_msg: '用户名不能为空'
185
+ )
186
+
187
+ ensure_git_user_field(
188
+ key: 'user.email',
189
+ label: 'Git 提交邮箱',
190
+ hint: '请确保与注册 gitee.com 等代码仓库使用的邮箱一致(否则提交可能无法关联到个人账号)',
191
+ prompt: '请输入 Git 提交邮箱',
192
+ validator: ->(v) { v.strip.match?(/\A[^@\s]+@[^@\s]+\.[^@\s]+\z/) },
193
+ error_msg: '邮箱格式不合法,请输入形如 user@example.com 的地址'
194
+ )
195
+ end
196
+
197
+ def ensure_git_user_field(key:, label:, hint:, prompt:, validator:, error_msg:)
198
+ current = begin
199
+ Pindo::GitHandler.git!(%W(config --global --get #{key})).strip
200
+ rescue
201
+ ''
202
+ end
203
+
204
+ if !current.empty?
205
+ cli = HighLine.new
206
+ answer = cli.ask(" 当前#{label}是 #{current},是否修改?[y/N] ")
207
+ unless answer.to_s.strip.downcase.start_with?('y')
208
+ @final_configs << { desc: label, key: key, value: current, status: :kept }
209
+ return
210
+ end
211
+ else
212
+ Funlog.instance.fancyinfo_warning(" 当前#{label}未设置,需要设置")
213
+ end
214
+
215
+ puts ""
216
+ puts " ⚠ #{hint}"
217
+ puts ""
218
+
219
+ new_value = nil
220
+ cli = HighLine.new
221
+ loop do
222
+ new_value = cli.ask(" #{prompt}: ").to_s.strip
223
+ break if validator.call(new_value)
224
+ Funlog.instance.fancyinfo_warning(" #{error_msg}")
225
+ end
226
+
227
+ Pindo::GitHandler.git!(%W(config --global #{key} #{new_value}))
228
+ if current.empty?
229
+ @final_configs << { desc: label, key: key, value: new_value, status: :new, note: '新增' }
230
+ else
231
+ @final_configs << { desc: label, key: key, value: new_value, status: :updated, note: "更新: #{current} → #{new_value}" }
232
+ end
233
+ end
234
+
235
+ def apply_global_git_configs
236
+ if pindo_verbose?
237
+ Funlog.instance.fancyinfo_start("即将设置 #{GLOBAL_CONFIGS.size} 项全局 Git 配置(直接覆盖策略):")
238
+ GLOBAL_CONFIGS.each do |key, cfg|
239
+ Funlog.instance.fancyinfo_start(" - #{cfg[:desc]}:#{key} → #{cfg[:value]}")
240
+ end
241
+ end
242
+ GLOBAL_CONFIGS.each { |key, cfg| ensure_global_config(key, cfg[:value], cfg[:desc]) }
243
+ end
244
+
245
+ def ensure_global_config(key, expected, desc)
246
+ current = begin
247
+ Pindo::GitHandler.git!(%W(config --global --get #{key})).strip
248
+ rescue
249
+ ''
250
+ end
251
+
252
+ if current == expected
253
+ @final_configs << { desc: desc, key: key, value: expected, status: :kept }
254
+ elsif current.empty?
255
+ vstart(" #{desc}:#{key} 未设置,写入 #{expected}")
256
+ Pindo::GitHandler.git!(%W(config --global #{key} #{expected}))
257
+ @final_configs << { desc: desc, key: key, value: expected, status: :new, note: '新增' }
258
+ else
259
+ vstart(" #{desc}:#{key} 当前 #{current},覆盖为 #{expected}")
260
+ Pindo::GitHandler.git!(%W(config --global #{key} #{expected}))
261
+ @final_configs << { desc: desc, key: key, value: expected, status: :updated, note: "覆盖: #{current} → #{expected}" }
262
+ end
263
+ end
264
+
265
+ end
266
+ end
267
+ end
268
+ end
@@ -1,6 +1,8 @@
1
1
  require 'highline/import'
2
2
  require 'fileutils'
3
3
  require 'pindo/options/options'
4
+ require 'pindo/module/utils/git_repo_helper'
5
+ require 'pindo/module/utils/git_hook_helper'
4
6
 
5
7
  module Pindo
6
8
  class Command
@@ -8,28 +10,31 @@ module Pindo
8
10
  class Repoinit < Utils
9
11
 
10
12
  # 命令的简要说明 - 初始化git仓库配置
11
- self.summary = '初始化git仓库中git cliff的配置'
13
+ self.summary = '初始化git仓库配置(.gitignore、commit统计hook、git-cliff'
12
14
 
13
15
  # 命令的详细说明,包含用法示例
14
16
  self.description = <<-DESC
15
- 初始化git仓库中git cliff的配置。
17
+ 初始化git仓库配置。
16
18
 
17
19
  支持功能:
18
20
 
19
- * 初始化git cliff配置
21
+ * 检查并补充 .gitignore 规则(默认)
20
22
 
21
- * 生成配置文件
23
+ * 安装 commit 变更统计 hook(默认,支持普通仓库/子模块/Husky)
24
+
25
+ * 初始化 git-cliff 配置(需指定 --cliff)
22
26
 
23
27
  使用示例:
24
28
 
25
- $ pindo utils repoinit # 初始化配置
29
+ $ pindo utils repoinit # 检查 .gitignore + 安装统计 hook
30
+ $ pindo utils repoinit --cliff # 同时初始化 git-cliff
26
31
  DESC
27
32
 
28
33
  # 命令的参数列表
29
34
  self.arguments = []
30
35
 
31
36
  def self.option_items
32
- @option_items ||= Pindo::Options::UtilsOptions.select(:mode, :retag)
37
+ @option_items ||= Pindo::Options::UtilsOptions.select(:cliff)
33
38
  end
34
39
 
35
40
  def self.options
@@ -39,22 +44,34 @@ module Pindo
39
44
  def initialize(argv)
40
45
  @options = initialize_options(argv)
41
46
 
42
- @mode = @options[:mode] || 'minor'
43
- @force_retag = @options[:retag] || false
44
-
45
- unless ['major', 'minor', 'patch'].include?(@mode)
46
- raise Informative, "mode参数必须是 major, minor 或 patch"
47
- end
47
+ @enable_cliff = @options[:cliff] || false
48
48
 
49
49
  super
50
50
  @additional_args = argv.remainder!
51
51
  end
52
52
 
53
53
  def run
54
-
54
+
55
55
  pindo_project_dir = Dir.pwd
56
- build_helper = Pindo::BuildHelper.share_instance
57
- Pindo::GitRepoHelper.share_instance.check_check_and_install_cliff(pindo_project_dir)
56
+
57
+ unless Pindo::GitHandler.is_git_directory?(local_repo_dir: pindo_project_dir)
58
+ Funlog.instance.fancyinfo_warning("当前目录不是 Git 仓库,跳过初始化")
59
+ return
60
+ end
61
+
62
+ current_git_root_path = Pindo::GitHandler.git_root_directory(local_repo_dir: pindo_project_dir)
63
+ git_repo_helper = Pindo::GitRepoHelper.share_instance
64
+
65
+ # 1. 检查并补充 .gitignore 规则
66
+ git_repo_helper.check_gitignore(current_git_root_path)
67
+
68
+ # 2. 安装 commit 变更统计 hook(主仓库 + 子模块,支持 Husky)
69
+ Pindo::GitHookHelper.share_instance.install_commit_stats_hook(current_git_root_path)
70
+
71
+ # 3. 指定 --cliff 参数时,才检测安装 git-cliff 并初始化配置
72
+ if @enable_cliff
73
+ git_repo_helper.check_and_install_cliff(pindo_project_dir)
74
+ end
58
75
 
59
76
  end
60
77
 
@@ -1,7 +1,7 @@
1
1
  require 'highline/import'
2
2
  require 'fileutils'
3
3
  require 'pindo/base/git_handler'
4
- require 'pindo/module/build/git_repo_helper'
4
+ require 'pindo/module/utils/git_repo_helper'
5
5
  require 'pindo/module/task/task_manager'
6
6
  require 'pindo/module/task/model/git/git_commit_task'
7
7
  require 'pindo/module/task/model/git/git_tag_task'
@@ -11,6 +11,7 @@ require 'pindo/command/utils/renewcert'
11
11
  # require 'pindo/command/utils/copyconfig'
12
12
  # require 'pindo/command/utils/allcopyconfig'
13
13
  require 'pindo/command/utils/repoinit'
14
+ require 'pindo/command/utils/gitconfig'
14
15
  # require 'pindo/command/utils/tag'
15
16
  require 'pindo/command/utils/updateconfig'
16
17
  require 'pindo/command/utils/fabric'