pindo 5.20.11 → 5.20.12

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: 443ddd0df9f6ac9c94a64704d56d2af1e4e5787bf986e398460c68c0500af1d2
4
+ data.tar.gz: b53590128f05104d85133f4bbac18f4216047e1123d8f5e07d7967aaf0afb035
5
5
  SHA512:
6
- metadata.gz: bb5b006a2a3958aac7a595a60c1768a34b6b0fd56d9b817a3f83e5bc4bceb036f097e66ca66a052185bc5353d742038e98367376741f4456817aad9f5ff0b8b4
7
- data.tar.gz: 1c9ec36b47e44a6e09c074963b800f820ca29269b83df091a0175181d14c6f76e70df3525452ce5a7a238a1a045ecfbc14c71372c9ef87af95c293cd14008556
6
+ metadata.gz: c97ecc8b4bbb5e7a1e2d798093ccc899398022c1bbc50b5bbe9e9470878278d964ffbf7e2cff1e2c05336c542b03fa1446d3930af5d48383d5b14811d0e350bc
7
+ data.tar.gz: 0b21dfd8f1ae5b872bff36d03809b7ae38c17c453c86b12c7349394d35c463b9de121c59fa1b651c3dd6c49687a4ae494928389a1637d5c09731f101f796c719
@@ -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'
@@ -272,7 +289,7 @@ module Pindo
272
289
 
273
290
  # 设置默认值
274
291
  create_tag_type ||= Pindo::CreateTagType::NEW
275
- version_increase_type ||= Pindo::VersionIncreaseType::MINI
292
+ version_increase_type ||= Pindo::VersionIncreaseType::PATCH
276
293
 
277
294
  # 获取当前版本号
278
295
  current_version = get_current_version_from_tag(
@@ -286,35 +303,40 @@ 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:current_version 是起始基线而非"上一个已发布版本"
313
+ # 直接作为首个版本使用,不再自增,否则首包会落在 0.0.2(patch) 或 0.1.0(mini)
314
+ unless has_version_tag?(project_dir: project_dir, tag_prefixes: [tag_prefix])
315
+ Funlog.instance.fancyinfo_success("仓库暂无版本tag,使用初始版本号: #{current_version}")
316
+ return current_version
317
317
  end
318
+
319
+ # 已有tag但不在HEAD,根据 version_increase_type 进位
320
+ parts = current_version.split('.').map(&:to_i)
321
+ major = parts[0] || 0
322
+ minor = parts[1] || 0
323
+ patch = parts[2] || 0
324
+
325
+ case version_increase_type
326
+ when Pindo::VersionIncreaseType::MAIN
327
+ major += 1
328
+ minor = 0
329
+ patch = 0
330
+ when Pindo::VersionIncreaseType::MINI
331
+ minor += 1
332
+ patch = 0
333
+ when Pindo::VersionIncreaseType::PATCH
334
+ patch += 1
335
+ end
336
+
337
+ new_version = "#{major}.#{minor}.#{patch}"
338
+ Funlog.instance.fancyinfo_success("新的版本号是: #{new_version}")
339
+ new_version
318
340
  else
319
341
  current_version
320
342
  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}")
@@ -23,10 +23,12 @@ module Pindo
23
23
  description: '版本号增加方式: main(大版本), mini(小版本), patch(补丁版本)',
24
24
  type: String,
25
25
  env_name: 'PINDO_VERSION_INCREASE',
26
- default_value: 'mini',
26
+ default_value: 'patch',
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,7 +112,8 @@ module Pindo
110
112
  when 'patch'
111
113
  Pindo::VersionIncreaseType::PATCH
112
114
  else
113
- Pindo::VersionIncreaseType::MINI
115
+ # 兜底与 ver_inc 的默认值保持一致,避免取值异常时静默退回 mini
116
+ Pindo::VersionIncreaseType::PATCH
114
117
  end
115
118
  end
116
119
 
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.12"
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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade