pindo 5.20.11 → 5.20.13

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: 98bd5c08bca96f252deafefe0e50ee77483715b02614fee7951d2de03ee80127
4
- data.tar.gz: bcc83560e3cd589064f3cc853769de9dfbbb50cbb6bbb5e105d78be13ed1e410
3
+ metadata.gz: a148065eb3f578b891b22cd6284901b43479d5314de1218dd4a37e1b012d401d
4
+ data.tar.gz: 657bda628f64b43964550bad1ce409f65656d2abe9901883439f41e35a4798c7
5
5
  SHA512:
6
- metadata.gz: bb5b006a2a3958aac7a595a60c1768a34b6b0fd56d9b817a3f83e5bc4bceb036f097e66ca66a052185bc5353d742038e98367376741f4456817aad9f5ff0b8b4
7
- data.tar.gz: 1c9ec36b47e44a6e09c074963b800f820ca29269b83df091a0175181d14c6f76e70df3525452ce5a7a238a1a045ecfbc14c71372c9ef87af95c293cd14008556
6
+ metadata.gz: 4c59422cec9fc11032086e2a1378318660842746d8512a50eabc0284b1fc5b37890d173cd52ddb7f581e094cfadde08132fd87e265ba20ac67d48f8f0d429a4b
7
+ data.tar.gz: beb39d7e8b0677746817e2ce7271feafbf20646b909850ad2c4d22334c45f7b0d14624268acd4c02617b2551def40ad7c39b7d24ea5d1213507d9395d9feff62
@@ -261,6 +261,23 @@ module Pindo
261
261
  build_number >= 1 && build_number <= 2**31 - 1
262
262
  end
263
263
 
264
+ # 判断仓库中是否已存在版本 tag
265
+ # 查找口径与 get_current_version_from_tag 保持一致
266
+ # @param project_dir [String] 项目目录
267
+ # @param tag_prefixes [Array<String>] tag前缀列表
268
+ # @return [Boolean] 是否存在版本tag
269
+ def has_version_tag?(project_dir:, tag_prefixes: nil)
270
+ raise ArgumentError, "项目目录不能为空" if project_dir.nil?
271
+
272
+ git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: project_dir)
273
+ return false unless git_root
274
+
275
+ prefixes = (tag_prefixes.nil? || tag_prefixes.empty?) ? ["v", "release", ""] : tag_prefixes
276
+ prefixes.any? do |prefix|
277
+ !Pindo::GitHandler.get_latest_version_tag(project_dir: git_root, tag_prefix: prefix).nil?
278
+ end
279
+ end
280
+
264
281
  # 计算构建版本号
265
282
  # @param project_dir [String] 项目目录
266
283
  # @param tag_prefix [String] tag前缀,默认 'v'
@@ -286,35 +303,43 @@ module Pindo
286
303
  # 不创建tag或重新创建当前tag,使用当前版本号
287
304
  current_version
288
305
  when Pindo::CreateTagType::NEW
289
- # 创建新tag,需要检查HEAD是否已有tag
306
+ # HEAD已有tag,不需要创建新tag,使用当前版本号
290
307
  if Pindo::GitHandler.head_has_version_tag?(project_dir: project_dir, tag_prefix: tag_prefix)
291
- # HEAD已有tag,不需要创建新tag,使用当前版本号
292
308
  Funlog.instance.fancyinfo_success("HEAD已存在tag,使用当前版本号: #{current_version}")
293
- current_version
294
- else
295
- # HEAD没有tag,根据 version_increase_type 计算新版本号
296
- # 解析版本号
297
- parts = current_version.split('.').map(&:to_i)
298
- major = parts[0] || 0
299
- minor = parts[1] || 0
300
- patch = parts[2] || 0
301
-
302
- case version_increase_type
303
- when Pindo::VersionIncreaseType::MAIN
304
- major += 1
305
- minor = 0
306
- patch = 0
307
- when Pindo::VersionIncreaseType::MINI
308
- minor += 1
309
- patch = 0
310
- when Pindo::VersionIncreaseType::PATCH
311
- patch += 1
312
- end
309
+ return current_version
310
+ end
313
311
 
314
- new_version = "#{major}.#{minor}.#{patch}"
315
- Funlog.instance.fancyinfo_success("新的版本号是: #{new_version}")
316
- new_version
312
+ # 仓库从未打过版本tag时从 0.0.0 起算,使首个版本由 version_increase_type 决定:
313
+ # patch => 0.0.1、mini => 0.1.0、main => 1.0.0。
314
+ # 此处不能直接用 current_version(0.0.1),那是"无版本"的占位值,
315
+ # 拿它自增会让首包落在 0.0.2(patch) 或 0.1.0 之上的错误位置。
316
+ base_version = if has_version_tag?(project_dir: project_dir, tag_prefixes: [tag_prefix])
317
+ current_version
318
+ else
319
+ "0.0.0"
320
+ end
321
+
322
+ # 根据 version_increase_type 进位
323
+ parts = base_version.split('.').map(&:to_i)
324
+ major = parts[0] || 0
325
+ minor = parts[1] || 0
326
+ patch = parts[2] || 0
327
+
328
+ case version_increase_type
329
+ when Pindo::VersionIncreaseType::MAIN
330
+ major += 1
331
+ minor = 0
332
+ patch = 0
333
+ when Pindo::VersionIncreaseType::MINI
334
+ minor += 1
335
+ patch = 0
336
+ when Pindo::VersionIncreaseType::PATCH
337
+ patch += 1
317
338
  end
339
+
340
+ new_version = "#{major}.#{minor}.#{patch}"
341
+ Funlog.instance.fancyinfo_success("新的版本号是: #{new_version}")
342
+ new_version
318
343
  else
319
344
  current_version
320
345
  end
@@ -67,6 +67,12 @@ module Pindo
67
67
 
68
68
  cached_params = @cache_data.dig(@current_directory.to_sym, @current_command.to_sym)
69
69
 
70
+ # 过滤已标记为不可缓存的参数:写入端(save_cache_to_file)会跳过这类参数,
71
+ # 但历史缓存文件中可能残留旧值。不过滤的话,参数由 cacheable:true 改为 false 后旧值仍会生效。
72
+ if cached_params.is_a?(Hash)
73
+ cached_params = cached_params.select { |key, _| is_cacheable?(key) }
74
+ end
75
+
70
76
  # 没有缓存数据,直接返回空Hash
71
77
  unless cached_params && cached_params.is_a?(Hash) && cached_params.any?
72
78
  log_verbose("没有找到缓存参数: #{@current_directory} / #{@current_command}")
@@ -26,7 +26,9 @@ module Pindo
26
26
  default_value: 'mini',
27
27
  aliases: [:version_increase],
28
28
  optional: true,
29
- cacheable: true, # 存入文件缓存
29
+ # 不进缓存:该参数表达"本次如何递增版本",属一次性决策。
30
+ # 若缓存,一次 --ver_inc=main 会让该项目此后每次打包都跳大版本。
31
+ cacheable: false,
30
32
  verify_block: proc do |value|
31
33
  unless VERSION_INCREASE_TYPES.include?(value.to_s.downcase)
32
34
  raise "版本增加类型错误: #{value},必须是 main、mini 或 patch 之一"
@@ -110,6 +112,7 @@ module Pindo
110
112
  when 'patch'
111
113
  Pindo::VersionIncreaseType::PATCH
112
114
  else
115
+ # 兜底与 ver_inc 的默认值保持一致
113
116
  Pindo::VersionIncreaseType::MINI
114
117
  end
115
118
  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.11"
9
+ VERSION = "5.20.13"
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.11
4
+ version: 5.20.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade