pindo 4.9.0 → 4.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pindo/base/githelper.rb +201 -77
- data/lib/pindo/command/dev/tag.rb +184 -0
- data/lib/pindo/command/dev.rb +1 -1
- data/lib/pindo/command/unity/ipa.rb +28 -6
- data/lib/pindo/config/pindouserlocalconfig.rb +17 -1
- data/lib/pindo/module/build/buildhelper.rb +143 -0
- data/lib/pindo/{client → module/build}/unityhelper.rb +93 -12
- data/lib/pindo/module/pgyer/pgyerhelper.rb +38 -69
- data/lib/pindo/version.rb +1 -1
- metadata +5 -4
- data/lib/pindo/command/dev/pub.rb +0 -171
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c74254c898c4aed8258d9c19ab0e74bdbce31fd1e3744e145c2ad1ec7e9112c7
|
4
|
+
data.tar.gz: a06a58190d7de3995e41939902fddbc1b104faed1e8c8c6cf210f505a84adfec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88df3e2378300ed5f4bba46ebca8d1aee43225f3910074dd38a532b2bda32ba9e829cd813be6b853bd2c32be5e9fb376d09faea65482b7e0e2078e2abcdb0398
|
7
|
+
data.tar.gz: 541c1a5452e254c898ec992c82037e181fd7d5ce49a0bfeb3827b54efe0ba6b09dc116be108910bcddabf59c43a3d0612b70a44e9f4881072ed05295dbf4b5ab
|
data/lib/pindo/base/githelper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'fileutils'
|
3
2
|
require 'pindo/base/executable'
|
4
3
|
require 'etc'
|
@@ -10,13 +9,9 @@ module Pindo
|
|
10
9
|
executable :git
|
11
10
|
|
12
11
|
def prepare_gitenv()
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
system command
|
17
|
-
command = "git config --global user.name #{usrname}"
|
18
|
-
system command
|
19
|
-
|
12
|
+
usrname = Etc.getlogin
|
13
|
+
git!(%W(config --global user.email #{usrname}@example.com))
|
14
|
+
git!(%W(config --global user.name #{usrname}))
|
20
15
|
end
|
21
16
|
|
22
17
|
def is_git_directory?(local_repo_dir: nil)
|
@@ -132,7 +127,7 @@ module Pindo
|
|
132
127
|
return result
|
133
128
|
end
|
134
129
|
|
135
|
-
def add_tag_with_check(local_repo_dir:nil, tag_name:nil)
|
130
|
+
def add_tag_with_check(local_repo_dir:nil, tag_name:nil, check: true)
|
136
131
|
|
137
132
|
if remote_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
138
133
|
puts
|
@@ -141,10 +136,13 @@ module Pindo
|
|
141
136
|
puts
|
142
137
|
puts "仓库已经存在同样tag:#{tag_name} !!!"
|
143
138
|
|
144
|
-
|
145
|
-
|
146
|
-
|
139
|
+
if check
|
140
|
+
answer = agree("确定删除远程仓库的tag, 重新添加tag:#{tag_name}吗(Y/n)?:")
|
141
|
+
unless answer
|
142
|
+
raise Informative, "添加tag异常!!!"
|
143
|
+
end
|
147
144
|
end
|
145
|
+
|
148
146
|
if local_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
149
147
|
git!(%W(-C #{local_repo_dir} tag -d #{tag_name}))
|
150
148
|
end
|
@@ -307,9 +305,7 @@ module Pindo
|
|
307
305
|
$stdin.flush
|
308
306
|
Funlog.instance.fancyinfo_success("仓库#{local_repo_dir}更新完成!")
|
309
307
|
rescue StandardError => e
|
310
|
-
|
311
308
|
Funlog.instance.fancyinfo_error("仓库#{local_repo_dir}更新失败!")
|
312
|
-
|
313
309
|
raise Informative, e.to_s
|
314
310
|
end
|
315
311
|
|
@@ -453,74 +449,202 @@ module Pindo
|
|
453
449
|
|
454
450
|
|
455
451
|
|
452
|
+
# 处理未提交的文件
|
453
|
+
# @param project_dir [String] 项目目录路径
|
454
|
+
# @raise [Informative] 当用户选择退出或需要手动处理文件时抛出
|
456
455
|
def process_need_add_files(project_dir:nil)
|
456
|
+
raise ArgumentError, "项目目录不能为空" if project_dir.nil?
|
457
|
+
|
458
|
+
current_project_dir = project_dir
|
459
|
+
origin_path = Dir.pwd
|
460
|
+
|
461
|
+
begin
|
462
|
+
Dir.chdir(current_project_dir)
|
463
|
+
|
464
|
+
# 获取当前分支信息
|
465
|
+
coding_branch = git!(%W(-C #{current_project_dir} rev-parse --abbrev-ref HEAD)).strip
|
466
|
+
# 重置暂存区
|
467
|
+
git!(%W(-C #{current_project_dir} restore --staged #{current_project_dir}))
|
468
|
+
|
469
|
+
# 获取未跟踪和已修改的文件
|
470
|
+
files_list = git!(%W(-C #{current_project_dir} ls-files --other --modified --exclude-standard)) || []
|
471
|
+
|
472
|
+
if files_list.nil? || files_list.empty?
|
473
|
+
return
|
474
|
+
end
|
457
475
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
476
|
+
# 显示文件状态
|
477
|
+
display_file_status(coding_branch, files_list)
|
478
|
+
|
479
|
+
# 处理用户选择
|
480
|
+
process_user_choice(current_project_dir, coding_branch)
|
481
|
+
|
482
|
+
ensure
|
483
|
+
Dir.chdir(origin_path)
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
private
|
488
|
+
|
489
|
+
def display_file_status(branch, files)
|
490
|
+
puts "\n当前所在分支:#{branch}有下面这些文件没有提交:"
|
491
|
+
puts "\n#{files}\n"
|
492
|
+
end
|
493
|
+
|
494
|
+
def process_user_choice(project_dir, branch)
|
495
|
+
process_types = ["全部提交", "全部删除", "退出"]
|
496
|
+
cli = HighLine.new
|
497
|
+
menu_choice = "None"
|
498
|
+
|
499
|
+
cli.choose do |menu|
|
500
|
+
menu.header = "对以上未提交的文件, 有下列处理方式"
|
501
|
+
menu.prompt = "请选择如何处理(1/2/3...):"
|
502
|
+
process_types.each do |item|
|
503
|
+
menu.choice(item) { |choice| menu_choice = choice }
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
puts "选择的处理方式为: #{menu_choice}"
|
508
|
+
|
509
|
+
case menu_choice
|
510
|
+
when "全部提交"
|
511
|
+
handle_commit_all(project_dir, branch)
|
512
|
+
when "全部删除"
|
513
|
+
handle_delete_all(project_dir, branch)
|
514
|
+
else
|
515
|
+
raise Informative, "请手动处理未提交的文件!!!"
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def handle_commit_all(project_dir, branch)
|
520
|
+
message = ask('请输入提交的备注信息: ') || "release code"
|
521
|
+
|
522
|
+
Funlog.instance.fancyinfo_start("开始提交文件...")
|
523
|
+
git! ['add', '-A']
|
524
|
+
git! ['commit', '-m', message]
|
525
|
+
git!(%W(-C #{project_dir} fetch origin))
|
526
|
+
Funlog.instance.fancyinfo_success("commit文件完成!")
|
527
|
+
Funlog.instance.fancyinfo_start("正在push...")
|
528
|
+
if remote_branch_exists?(local_repo_dir: project_dir, branch: branch)
|
529
|
+
git!(%W(-C #{project_dir} branch --set-upstream-to=origin/#{branch} #{branch}))
|
530
|
+
git! ['pull']
|
531
|
+
git! ['push']
|
532
|
+
else
|
533
|
+
git!(%W(-C #{project_dir} push --set-upstream origin #{branch}))
|
534
|
+
end
|
535
|
+
Funlog.instance.fancyinfo_success("push文件完成!")
|
536
|
+
end
|
537
|
+
def handle_delete_all(project_dir, branch)
|
538
|
+
answer = agree("有未提交的文件,确认删除?(Y/n):")
|
539
|
+
unless answer
|
540
|
+
raise Informative, "请手动处理未提交的文件!!!"
|
541
|
+
end
|
542
|
+
|
543
|
+
git!(%W(-C #{project_dir} reset --hard))
|
544
|
+
git!(%W(-C #{project_dir} clean -dfx))
|
545
|
+
git!(%W(-C #{project_dir} branch --set-upstream-to=origin/#{branch} #{branch}))
|
546
|
+
git!(%W(-C #{project_dir} pull))
|
547
|
+
end
|
520
548
|
|
521
|
-
|
549
|
+
# 获取最新的版本标签
|
550
|
+
# @param project_dir [String] 项目目录路径
|
551
|
+
# @return [String, nil] 返回最新的版本标签,如果没有则返回nil
|
552
|
+
def get_latest_version_tag(project_dir:nil, tag_prefix:"v")
|
553
|
+
return nil unless project_dir && File.exist?(project_dir)
|
554
|
+
|
555
|
+
begin
|
556
|
+
# 获取所有以v开头的标签并按版本号排序
|
557
|
+
tags = git!(%W(-C #{project_dir} tag -l #{tag_prefix}*)).split("\n")
|
558
|
+
return nil if tags.empty?
|
559
|
+
|
560
|
+
# 按版本号排序(假设格式为 v1.2.3)
|
561
|
+
sorted_tags = tags.sort_by do |tag|
|
562
|
+
tag.gsub(tag_prefix, '').split('.').map(&:to_i)
|
563
|
+
end
|
564
|
+
|
565
|
+
sorted_tags.last
|
566
|
+
rescue StandardError => e
|
567
|
+
nil
|
522
568
|
end
|
569
|
+
end
|
523
570
|
|
571
|
+
# 创建新的版本标签
|
572
|
+
# @param project_dir [String] 项目目录路径
|
573
|
+
# @param tag_prefix [String] 标签前缀
|
574
|
+
# @param increment_mode [String] 版本号增加模式 ("major", "minor", "patch")
|
575
|
+
# @param force_retag [Boolean] 是否强制重新打最新的tag
|
576
|
+
# @return [String] 返回新创建的版本标签或已存在的标签
|
577
|
+
# @raise [ArgumentError] 当项目目录不存在时抛出
|
578
|
+
def create_next_version_tag(project_dir:nil, tag_prefix:"v", increment_mode:"minor", force_retag:false)
|
579
|
+
raise ArgumentError, "项目目录不能为空" if project_dir.nil?
|
580
|
+
|
581
|
+
latest_tag = get_latest_version_tag(project_dir: project_dir, tag_prefix: tag_prefix)
|
582
|
+
if latest_tag.nil?
|
583
|
+
latest_tag = get_latest_version_tag(project_dir: project_dir, tag_prefix: "")
|
584
|
+
end
|
585
|
+
# 如果没有任何tag,创建初始版本
|
586
|
+
if latest_tag.nil?
|
587
|
+
new_tag = tag_prefix + "1.0.0"
|
588
|
+
add_tag_with_check(local_repo_dir: project_dir, tag_name: new_tag, check: false)
|
589
|
+
Funlog.instance.fancyinfo_success("创建新tag完成!")
|
590
|
+
return new_tag
|
591
|
+
end
|
592
|
+
|
593
|
+
if is_tag_at_head?(project_dir: project_dir, tag_name: latest_tag)
|
594
|
+
return latest_tag
|
595
|
+
end
|
596
|
+
|
597
|
+
if force_retag && latest_tag
|
598
|
+
# 删除并重新打tag
|
599
|
+
Funlog.instance.fancyinfo_update("正在重新打tag: #{latest_tag}")
|
600
|
+
remove_tag(local_repo_dir: project_dir, tag_name: latest_tag)
|
601
|
+
add_tag_with_check(local_repo_dir: project_dir, tag_name: latest_tag)
|
602
|
+
Funlog.instance.fancyinfo_success("重新打tag完成!")
|
603
|
+
return latest_tag
|
604
|
+
end
|
605
|
+
|
606
|
+
# 解析当前版本号
|
607
|
+
version_numbers = latest_tag.gsub(tag_prefix, '').split('.').map(&:to_i)
|
608
|
+
major, minor, patch = version_numbers
|
609
|
+
|
610
|
+
# 根据increment_mode增加版本号
|
611
|
+
case increment_mode
|
612
|
+
when "major"
|
613
|
+
major += 1
|
614
|
+
minor = 0
|
615
|
+
patch = 0
|
616
|
+
when "minor"
|
617
|
+
minor += 1
|
618
|
+
patch = 0
|
619
|
+
when "patch"
|
620
|
+
patch += 1
|
621
|
+
end
|
622
|
+
|
623
|
+
new_tag = tag_prefix + "#{major}.#{minor}.#{patch}"
|
624
|
+
add_tag_with_check(local_repo_dir: project_dir, tag_name: new_tag, check: false)
|
625
|
+
Funlog.instance.fancyinfo_success("创建新tag完成!")
|
626
|
+
new_tag
|
627
|
+
end
|
628
|
+
|
629
|
+
# 检查tag是否在指定的commit上
|
630
|
+
# @param project_dir [String] 项目目录路径
|
631
|
+
# @param tag_name [String] 标签名称
|
632
|
+
# @return [Boolean] 如果tag在当前HEAD上返回true,否则返回false
|
633
|
+
def is_tag_at_head?(project_dir:nil, tag_name:nil)
|
634
|
+
return false if project_dir.nil? || tag_name.nil?
|
635
|
+
|
636
|
+
begin
|
637
|
+
# 获取tag的commit hash
|
638
|
+
tag_commit = git!(%W(-C #{project_dir} rev-parse #{tag_name})).strip
|
639
|
+
# 获取HEAD的commit hash
|
640
|
+
head_commit = git!(%W(-C #{project_dir} rev-parse HEAD)).strip
|
641
|
+
|
642
|
+
# 比较两个commit hash是否相同
|
643
|
+
tag_commit == head_commit
|
644
|
+
rescue StandardError => e
|
645
|
+
false
|
646
|
+
end
|
647
|
+
end
|
524
648
|
|
525
649
|
end
|
526
650
|
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Pindo
|
5
|
+
class Command
|
6
|
+
class Dev < Command
|
7
|
+
class Tag < Dev
|
8
|
+
self.summary = '发布代码,添加tag,添加发布信息,并合并到发布分支'
|
9
|
+
self.description = <<-DESC
|
10
|
+
发布代码,添加tag,添加发布信息,并合并到发布分支。
|
11
|
+
|
12
|
+
支持功能:
|
13
|
+
* 处理未提交的文件
|
14
|
+
* 添加版本tag
|
15
|
+
* 合并到发布分支
|
16
|
+
|
17
|
+
使用示例:
|
18
|
+
$ pindo dev pub # 使用minor模式创建tag
|
19
|
+
$ pindo dev pub --mode=major # 使用major模式创建tag
|
20
|
+
$ pindo dev pub --mode=patch # 使用patch模式创建tag
|
21
|
+
$ pindo dev pub --retag # 强制重新打tag
|
22
|
+
DESC
|
23
|
+
self.arguments = []
|
24
|
+
|
25
|
+
def self.options
|
26
|
+
[
|
27
|
+
['--mode', '指定版本号增加模式(major/minor/patch),默认minor'],
|
28
|
+
['--retag', '强制重新打最新的tag']
|
29
|
+
].concat(super)
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(argv)
|
33
|
+
@mode = argv.option('mode') || 'minor'
|
34
|
+
@force_retag = argv.flag?('retag', false)
|
35
|
+
|
36
|
+
unless ['major', 'minor', 'patch'].include?(@mode)
|
37
|
+
raise Informative, "mode参数必须是 major, minor 或 patch"
|
38
|
+
end
|
39
|
+
|
40
|
+
super
|
41
|
+
@additional_args = argv.remainder!
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
current_project_dir = Dir.pwd
|
46
|
+
|
47
|
+
# 检查当前目录是否是git仓库
|
48
|
+
unless is_git_directory?(local_repo_dir: current_project_dir)
|
49
|
+
Funlog.instance.fancyinfo_error("当前目录不是git仓库")
|
50
|
+
raise Informative, "请在git仓库目录下执行此命令"
|
51
|
+
end
|
52
|
+
|
53
|
+
# 获取git仓库根目录
|
54
|
+
root_dir = git_root_directory(local_repo_dir: current_project_dir)
|
55
|
+
if root_dir.nil?
|
56
|
+
Funlog.instance.fancyinfo_error("无法获取git仓库根目录")
|
57
|
+
raise Informative, "获取git仓库根目录失败"
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
release_branch = "master"
|
63
|
+
process_need_add_files(project_dir: root_dir)
|
64
|
+
|
65
|
+
current_branch = git!(%W(-C #{root_dir} rev-parse --abbrev-ref HEAD)).strip
|
66
|
+
coding_branch = current_branch
|
67
|
+
|
68
|
+
Funlog.instance.fancyinfo_start("开始合并到#{release_branch}分支")
|
69
|
+
merge_to_release_branch(
|
70
|
+
project_dir: root_dir,
|
71
|
+
release_branch: release_branch,
|
72
|
+
coding_branch: coding_branch
|
73
|
+
)
|
74
|
+
|
75
|
+
add_release_tag(
|
76
|
+
project_dir: root_dir,
|
77
|
+
increment_mode: @mode,
|
78
|
+
force_retag: @force_retag
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_release_tag(project_dir: nil, increment_mode: "minor", force_retag: false)
|
83
|
+
raise ArgumentError, "项目目录不能为空" if project_dir.nil?
|
84
|
+
|
85
|
+
Funlog.instance.fancyinfo_start("开始创建初tag")
|
86
|
+
latest_tag = get_latest_version_tag(project_dir: project_dir)
|
87
|
+
if latest_tag.nil?
|
88
|
+
new_tag = create_next_version_tag(
|
89
|
+
project_dir: project_dir,
|
90
|
+
tag_prefix: "v",
|
91
|
+
increment_mode: increment_mode,
|
92
|
+
force_retag: false
|
93
|
+
)
|
94
|
+
Funlog.instance.fancyinfo_success("创建初始tag: #{new_tag}")
|
95
|
+
Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
if is_tag_at_head?(project_dir: project_dir, tag_name: latest_tag)
|
100
|
+
Funlog.instance.fancyinfo_success("当前commit已有tag: #{latest_tag},无需重新打tag")
|
101
|
+
Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
|
102
|
+
return
|
103
|
+
end
|
104
|
+
|
105
|
+
Funlog.instance.fancyinfo_success("最近的上次tag是: #{latest_tag} ")
|
106
|
+
new_tag = create_next_version_tag(
|
107
|
+
project_dir: project_dir,
|
108
|
+
tag_prefix: "v",
|
109
|
+
increment_mode: increment_mode,
|
110
|
+
force_retag: force_retag
|
111
|
+
)
|
112
|
+
|
113
|
+
Funlog.instance.fancyinfo_success("当前仓库的tag: #{new_tag}")
|
114
|
+
Funlog.instance.fancyinfo_success("仓库路径: #{project_dir}")
|
115
|
+
end
|
116
|
+
|
117
|
+
def merge_to_release_branch(project_dir: nil, release_branch: nil, coding_branch: nil)
|
118
|
+
current_project_dir = project_dir
|
119
|
+
Funlog.instance.fancyinfo_start("开始合并到#{release_branch}分支")
|
120
|
+
if !coding_branch.eql?(release_branch)
|
121
|
+
coding_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{coding_branch})).strip
|
122
|
+
release_branch_commit_id = "111"
|
123
|
+
|
124
|
+
if remote_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
|
125
|
+
Funlog.instance.fancyinfo_update("存在#{release_branch}远程分支")
|
126
|
+
if local_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
|
127
|
+
Funlog.instance.fancyinfo_update("存在#{release_branch}本地分支")
|
128
|
+
git!(%W(-C #{current_project_dir} checkout #{release_branch}))
|
129
|
+
else
|
130
|
+
Funlog.instance.fancyinfo_update("存在#{release_branch}远程分支")
|
131
|
+
Funlog.instance.fancyinfo_update("不存在#{release_branch}本地分支")
|
132
|
+
git!(%W(-C #{current_project_dir} checkout -b #{release_branch} origin/#{release_branch}))
|
133
|
+
end
|
134
|
+
|
135
|
+
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
|
136
|
+
git!(%W(-C #{current_project_dir} fetch origin #{release_branch}))
|
137
|
+
git!(%W(-C #{current_project_dir} merge origin/#{release_branch}))
|
138
|
+
|
139
|
+
res_data = Executable.capture_command('git', %W(merge #{coding_branch}), :capture => :out)
|
140
|
+
|
141
|
+
conflict_filelist = git!(%W(-C #{current_project_dir} diff --name-only --diff-filter=U --relative))
|
142
|
+
if !conflict_filelist.nil? && conflict_filelist.size > 0
|
143
|
+
puts "合并代码冲突, 冲突文件如下:"
|
144
|
+
raise Informative, "请手动处理冲突的文件!!!"
|
145
|
+
else
|
146
|
+
git!(%W(-C #{current_project_dir} push))
|
147
|
+
Funlog.instance.fancyinfo_success("代码已经合并到#{release_branch}分支")
|
148
|
+
release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
|
149
|
+
end
|
150
|
+
|
151
|
+
else
|
152
|
+
if local_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
|
153
|
+
Funlog.instance.fancyinfo_update("不存在#{release_branch}远程分支")
|
154
|
+
Funlog.instance.fancyinfo_update("存在#{release_branch}本地分支")
|
155
|
+
git!(%W(-C #{current_project_dir} checkout #{release_branch}))
|
156
|
+
git!(%W(-C #{current_project_dir} checkout -b #{release_branch}_temp))
|
157
|
+
git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
|
158
|
+
git!(%W(-C #{current_project_dir} branch -D #{release_branch}))
|
159
|
+
else
|
160
|
+
Funlog.instance.fancyinfo_update("不存在#{release_branch}远程分支")
|
161
|
+
Funlog.instance.fancyinfo_update("不存在#{release_branch}本地分支")
|
162
|
+
end
|
163
|
+
|
164
|
+
git!(%W(-C #{current_project_dir} checkout -b #{release_branch}))
|
165
|
+
git!(%W(-C #{current_project_dir} push origin #{release_branch}))
|
166
|
+
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
|
167
|
+
|
168
|
+
Funlog.instance.fancyinfo_success("代码已经合并到#{release_branch}分支")
|
169
|
+
release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
|
170
|
+
end
|
171
|
+
|
172
|
+
git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
|
173
|
+
if !release_branch_commit_id.eql?(coding_branch_commit_id)
|
174
|
+
git!(%W(-C #{current_project_dir} merge #{release_branch}))
|
175
|
+
Funlog.instance.fancyinfo_success("已将#{release_branch}合并到#{coding_branch}")
|
176
|
+
end
|
177
|
+
else
|
178
|
+
Funlog.instance.fancyinfo_success("代码处于#{coding_branch}分支,无需合并")
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
data/lib/pindo/command/dev.rb
CHANGED
@@ -3,7 +3,7 @@ require 'xcodeproj'
|
|
3
3
|
require 'find'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'pindo/base/executable'
|
6
|
-
require 'pindo/
|
6
|
+
require 'pindo/module/build/unityhelper'
|
7
7
|
|
8
8
|
module Pindo
|
9
9
|
class Command
|
@@ -49,7 +49,8 @@ module Pindo
|
|
49
49
|
['--proj', '指定上传到测试平台的项目名称'],
|
50
50
|
['--upload', '上传编译后的IPA到测试平台'],
|
51
51
|
['--send', '上传成功后发送测试通知'],
|
52
|
-
['--base', 'Unity工程编译lib模式']
|
52
|
+
['--base', 'Unity工程编译lib模式'],
|
53
|
+
['--unity-version', '切换Unity版本']
|
53
54
|
].concat(super)
|
54
55
|
end
|
55
56
|
|
@@ -61,6 +62,8 @@ module Pindo
|
|
61
62
|
@args_send_flag = argv.flag?('send', false)
|
62
63
|
@args_deploy_flag = argv.flag?('deploy', false)
|
63
64
|
@args_base_flag = argv.flag?('base', false)
|
65
|
+
@force_select_unity = argv.flag?('unity-version', false)
|
66
|
+
|
64
67
|
|
65
68
|
if @args_send_flag
|
66
69
|
@args_upload_flag = true
|
@@ -70,10 +73,15 @@ module Pindo
|
|
70
73
|
end
|
71
74
|
|
72
75
|
def export_ios_project(project_path, pindo_ios_project_dir, additional_args)
|
73
|
-
begin
|
74
|
-
# 获取 UnityHelper 实例
|
75
|
-
unity_helper = Pindo::Client::UnityHelper.share_instance
|
76
76
|
|
77
|
+
# 获取 UnityHelper 实例
|
78
|
+
unity_helper = Pindo::Client::UnityHelper.share_instance
|
79
|
+
# 获取 Unity 版本
|
80
|
+
unity_version = unity_helper.find_unity_path
|
81
|
+
puts "Unity 版本: #{unity_version}"
|
82
|
+
|
83
|
+
begin
|
84
|
+
|
77
85
|
# 执行Unity命令
|
78
86
|
result = unity_helper.execute_unity_command(
|
79
87
|
project_path,
|
@@ -104,6 +112,19 @@ module Pindo
|
|
104
112
|
|
105
113
|
|
106
114
|
def run
|
115
|
+
pindo_unity_project_dir = Dir.pwd
|
116
|
+
|
117
|
+
# 检查是否是Unity工程
|
118
|
+
unity_helper = Pindo::Client::UnityHelper.share_instance
|
119
|
+
|
120
|
+
if @force_select_unity
|
121
|
+
puts "强制选择Unity版本"
|
122
|
+
unity_helper.find_unity_path(change_unity_version:true)
|
123
|
+
end
|
124
|
+
|
125
|
+
unless unity_helper.unity_project?(pindo_unity_project_dir)
|
126
|
+
raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
|
127
|
+
end
|
107
128
|
|
108
129
|
app_info_obj = nil
|
109
130
|
if @args_upload_flag
|
@@ -119,7 +140,7 @@ module Pindo
|
|
119
140
|
mainapp_bundleid = get_selected_dev_bundleid()
|
120
141
|
end
|
121
142
|
|
122
|
-
|
143
|
+
|
123
144
|
pindo_ios_project_dir = File.join(pindo_unity_project_dir, "Platform/iOS")
|
124
145
|
# 准备额外的参数
|
125
146
|
additional_args = {
|
@@ -156,6 +177,7 @@ module Pindo
|
|
156
177
|
|
157
178
|
Pindo::Command::Ios::Debug::run(args_temp)
|
158
179
|
|
180
|
+
|
159
181
|
|
160
182
|
end
|
161
183
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'fileutils'
|
3
2
|
require 'json'
|
4
3
|
|
@@ -115,5 +114,22 @@ module Pindo
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
117
|
+
def save
|
118
|
+
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
|
119
|
+
File.open(@pindo_user_local_config_file, "w") do |file|
|
120
|
+
file.write(JSON.pretty_generate(@pindo_user_local_config_json))
|
121
|
+
file.close
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def unity_version
|
126
|
+
@pindo_user_local_config_json['unity_version'] if @pindo_user_local_config_json
|
127
|
+
end
|
128
|
+
|
129
|
+
def unity_version=(version)
|
130
|
+
@pindo_user_local_config_json = @pindo_user_local_config_json || {}
|
131
|
+
@pindo_user_local_config_json['unity_version'] = version
|
132
|
+
end
|
133
|
+
|
118
134
|
end
|
119
135
|
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'xcodeproj' # 用于iOS项目检查
|
4
|
+
|
5
|
+
module Pindo
|
6
|
+
module Module
|
7
|
+
module Build
|
8
|
+
class BuildHelper
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def share_instance
|
13
|
+
instance
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def unity_project?(project_path)
|
18
|
+
# 检查Unity工程的关键文件和目录
|
19
|
+
project_settings_path = File.join(project_path, "ProjectSettings")
|
20
|
+
assets_path = File.join(project_path, "Assets")
|
21
|
+
packages_path = File.join(project_path, "Packages")
|
22
|
+
|
23
|
+
# Unity工程必须包含这些目录和文件
|
24
|
+
File.directory?(project_settings_path) &&
|
25
|
+
File.directory?(assets_path) &&
|
26
|
+
File.directory?(packages_path) &&
|
27
|
+
File.exist?(File.join(project_settings_path, "ProjectSettings.asset"))
|
28
|
+
end
|
29
|
+
|
30
|
+
def ios_project?(project_path)
|
31
|
+
# 检查iOS工程的关键文件
|
32
|
+
xcodeproj_files = Dir.glob(File.join(project_path, "*.xcodeproj"))
|
33
|
+
workspace_files = Dir.glob(File.join(project_path, "*.xcworkspace"))
|
34
|
+
|
35
|
+
# 至少要有.xcodeproj文件或.xcworkspace文件
|
36
|
+
return false if xcodeproj_files.empty? && workspace_files.empty?
|
37
|
+
|
38
|
+
if !xcodeproj_files.empty?
|
39
|
+
# 检查.xcodeproj内部结构
|
40
|
+
project_file = File.join(xcodeproj_files.first, "project.pbxproj")
|
41
|
+
return true if File.exist?(project_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
if !workspace_files.empty?
|
45
|
+
# 检查.xcworkspace内部结构
|
46
|
+
contents_file = File.join(workspace_files.first, "contents.xcworkspacedata")
|
47
|
+
return true if File.exist?(contents_file)
|
48
|
+
end
|
49
|
+
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
def android_project?(project_path)
|
54
|
+
# 检查Android工程的关键文件和目录
|
55
|
+
gradle_file = File.exist?(File.join(project_path, "build.gradle"))
|
56
|
+
settings_gradle = File.exist?(File.join(project_path, "settings.gradle"))
|
57
|
+
app_dir = File.directory?(File.join(project_path, "app"))
|
58
|
+
|
59
|
+
# Android Studio项目结构
|
60
|
+
if gradle_file && settings_gradle && app_dir
|
61
|
+
app_gradle = File.exist?(File.join(project_path, "app", "build.gradle"))
|
62
|
+
app_manifest = File.exist?(File.join(project_path, "app", "src", "main", "AndroidManifest.xml"))
|
63
|
+
return true if app_gradle && app_manifest
|
64
|
+
end
|
65
|
+
|
66
|
+
# 传统Eclipse项目结构
|
67
|
+
if File.directory?(File.join(project_path, "src"))
|
68
|
+
manifest = File.join(project_path, "AndroidManifest.xml")
|
69
|
+
return true if File.exist?(manifest)
|
70
|
+
end
|
71
|
+
|
72
|
+
false
|
73
|
+
end
|
74
|
+
|
75
|
+
def project_type(project_path)
|
76
|
+
raise ArgumentError, "项目路径不能为空" if project_path.nil? || project_path.empty?
|
77
|
+
raise ArgumentError, "项目路径不存在: #{project_path}" unless File.directory?(project_path)
|
78
|
+
|
79
|
+
return :unity if unity_project?(project_path)
|
80
|
+
return :ios if ios_project?(project_path)
|
81
|
+
return :android if android_project?(project_path)
|
82
|
+
:unknown
|
83
|
+
end
|
84
|
+
|
85
|
+
def project_type_name(project_path)
|
86
|
+
case project_type(project_path)
|
87
|
+
when :unity
|
88
|
+
"Unity"
|
89
|
+
when :ios
|
90
|
+
"iOS"
|
91
|
+
when :android
|
92
|
+
"Android"
|
93
|
+
else
|
94
|
+
"Unknown"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_project_name(project_path)
|
99
|
+
case project_type(project_path)
|
100
|
+
when :unity
|
101
|
+
File.basename(project_path)
|
102
|
+
when :ios
|
103
|
+
xcodeproj = Dir.glob(File.join(project_path, "*.xcodeproj")).first
|
104
|
+
File.basename(xcodeproj, ".xcodeproj") if xcodeproj
|
105
|
+
when :android
|
106
|
+
settings_gradle = File.join(project_path, "settings.gradle")
|
107
|
+
if File.exist?(settings_gradle)
|
108
|
+
content = File.read(settings_gradle)
|
109
|
+
if content =~ /rootProject\.name\s*=\s*['"](.+)['"]/
|
110
|
+
$1
|
111
|
+
else
|
112
|
+
File.basename(project_path)
|
113
|
+
end
|
114
|
+
else
|
115
|
+
File.basename(project_path)
|
116
|
+
end
|
117
|
+
else
|
118
|
+
File.basename(project_path)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def get_project_version(project_path)
|
123
|
+
case project_type(project_path)
|
124
|
+
when :unity
|
125
|
+
version_file = File.join(project_path, "ProjectSettings", "ProjectVersion.txt")
|
126
|
+
if File.exist?(version_file)
|
127
|
+
content = File.read(version_file)
|
128
|
+
if content =~ /m_EditorVersion: (.*)/
|
129
|
+
$1.strip
|
130
|
+
end
|
131
|
+
end
|
132
|
+
when :ios
|
133
|
+
# 从Info.plist获取版本号
|
134
|
+
nil
|
135
|
+
when :android
|
136
|
+
# 从build.gradle获取版本号
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -17,7 +17,7 @@ module Pindo
|
|
17
17
|
"C:/Program Files/Unity/Hub/Editor/*/Unity.exe"
|
18
18
|
]
|
19
19
|
|
20
|
-
|
20
|
+
PINDO_UNITY_VERSION = "2021.3"
|
21
21
|
|
22
22
|
class << self
|
23
23
|
def share_instance
|
@@ -25,7 +25,7 @@ module Pindo
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def find_unity_path
|
28
|
+
def find_unity_path(change_unity_version:false)
|
29
29
|
paths = case RUBY_PLATFORM
|
30
30
|
when /darwin/
|
31
31
|
UNITY_MAC_PATHS
|
@@ -40,9 +40,8 @@ module Pindo
|
|
40
40
|
paths.each do |path|
|
41
41
|
if path.include?("*")
|
42
42
|
Dir.glob(path).each do |expanded_path|
|
43
|
-
# 从路径中提取版本号
|
44
43
|
version = extract_version_from_path(expanded_path)
|
45
|
-
if version
|
44
|
+
if version
|
46
45
|
unity_versions << {
|
47
46
|
path: expanded_path,
|
48
47
|
version: version
|
@@ -51,7 +50,7 @@ module Pindo
|
|
51
50
|
end
|
52
51
|
elsif File.exist?(path)
|
53
52
|
version = extract_version_from_path(path)
|
54
|
-
if version
|
53
|
+
if version
|
55
54
|
unity_versions << {
|
56
55
|
path: path,
|
57
56
|
version: version
|
@@ -61,12 +60,82 @@ module Pindo
|
|
61
60
|
end
|
62
61
|
|
63
62
|
if unity_versions.empty?
|
64
|
-
raise "
|
63
|
+
raise Informative, "未找到任何Unity版本"
|
64
|
+
end
|
65
|
+
|
66
|
+
if unity_versions.length == 1
|
67
|
+
selected_unity = unity_versions.first
|
68
|
+
return selected_unity[:path]
|
69
|
+
end
|
70
|
+
|
71
|
+
# 获取所有可用的主版本号
|
72
|
+
major_versions = unity_versions.map { |v|
|
73
|
+
v[:version].split('.')[0..1].join('.')
|
74
|
+
}.uniq.sort_by { |v| Gem::Version.new(v) }
|
75
|
+
|
76
|
+
if change_unity_version
|
77
|
+
# 让用户选择主版本号
|
78
|
+
puts "\n可用的Unity主版本:"
|
79
|
+
major_versions.each_with_index do |v, i|
|
80
|
+
puts "#{i + 1}. #{v}"
|
81
|
+
end
|
82
|
+
|
83
|
+
print "\n请选择Unity主版本 (1-#{major_versions.length}): "
|
84
|
+
choice = gets.chomp.to_i
|
85
|
+
|
86
|
+
if choice < 1 || choice > major_versions.length
|
87
|
+
raise Informative, "无效的选择"
|
88
|
+
end
|
89
|
+
|
90
|
+
selected_major_version = major_versions[choice - 1]
|
91
|
+
|
92
|
+
# 保存选择的主版本号
|
93
|
+
config = Pindo::Config::PindoUserLocalConfig.instance
|
94
|
+
config.unity_version = selected_major_version
|
95
|
+
config.save
|
96
|
+
|
97
|
+
# 在选定主版本下选择最新的版本
|
98
|
+
matching_versions = unity_versions.select { |v| v[:version].start_with?(selected_major_version) }
|
99
|
+
selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
|
100
|
+
|
101
|
+
return selected_unity[:path]
|
102
|
+
end
|
103
|
+
|
104
|
+
# 使用已保存的版本
|
105
|
+
config = Pindo::Config::PindoUserLocalConfig.instance
|
106
|
+
saved_version = config.unity_version
|
107
|
+
|
108
|
+
if saved_version
|
109
|
+
matching_versions = unity_versions.select { |v| v[:version].start_with?(saved_version) }
|
110
|
+
if matching_versions.any?
|
111
|
+
selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
|
112
|
+
return selected_unity[:path]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# 如果没有保存的版本或找不到匹配版本,让用户选择
|
117
|
+
puts "\n可用的Unity主版本:"
|
118
|
+
major_versions.each_with_index do |v, i|
|
119
|
+
puts "#{i + 1}. #{v}"
|
120
|
+
end
|
121
|
+
|
122
|
+
print "\n请选择Unity主版本 (1-#{major_versions.length}): "
|
123
|
+
choice = gets.chomp.to_i
|
124
|
+
|
125
|
+
if choice < 1 || choice > major_versions.length
|
126
|
+
raise Informative, "无效的选择"
|
65
127
|
end
|
66
128
|
|
67
|
-
|
68
|
-
|
69
|
-
|
129
|
+
selected_major_version = major_versions[choice - 1]
|
130
|
+
|
131
|
+
# 保存选择的主版本号
|
132
|
+
config.unity_version = selected_major_version
|
133
|
+
config.save
|
134
|
+
|
135
|
+
# 在选定主版本下选择最新的版本
|
136
|
+
matching_versions = unity_versions.select { |v| v[:version].start_with?(selected_major_version) }
|
137
|
+
selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
|
138
|
+
|
70
139
|
selected_unity[:path]
|
71
140
|
end
|
72
141
|
|
@@ -103,7 +172,7 @@ module Pindo
|
|
103
172
|
cmd_args << value.to_s if value
|
104
173
|
end
|
105
174
|
|
106
|
-
puts "
|
175
|
+
puts "Unity command: #{cmd_args.join(' ')}"
|
107
176
|
stdout, stderr, status = Open3.capture3(*cmd_args)
|
108
177
|
|
109
178
|
{
|
@@ -151,8 +220,8 @@ module Pindo
|
|
151
220
|
content = File.read(version_path)
|
152
221
|
if content =~ /m_EditorVersion: (.*)/
|
153
222
|
version = $1.strip
|
154
|
-
unless version.start_with?(
|
155
|
-
raise "Project Unity version (#{version}) does not match required version (#{
|
223
|
+
unless version.start_with?(PINDO_UNITY_VERSION)
|
224
|
+
raise "Project Unity version (#{version}) does not match required version (#{PINDO_UNITY_VERSION}.x)"
|
156
225
|
end
|
157
226
|
version
|
158
227
|
else
|
@@ -174,6 +243,18 @@ module Pindo
|
|
174
243
|
|
175
244
|
true
|
176
245
|
end
|
246
|
+
|
247
|
+
def unity_project?(project_path)
|
248
|
+
# 检查关键Unity工程文件和目录是否存在
|
249
|
+
project_settings_path = File.join(project_path, "ProjectSettings")
|
250
|
+
assets_path = File.join(project_path, "Assets")
|
251
|
+
packages_path = File.join(project_path, "Packages")
|
252
|
+
|
253
|
+
File.directory?(project_settings_path) &&
|
254
|
+
File.directory?(assets_path) &&
|
255
|
+
File.directory?(packages_path) &&
|
256
|
+
File.exist?(File.join(project_settings_path, "ProjectSettings.asset"))
|
257
|
+
end
|
177
258
|
end
|
178
259
|
end
|
179
260
|
end
|
@@ -145,6 +145,7 @@ module Pindo
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def start_upload(app_info_obj:nil, ipa_file_upload:nil, description:nil)
|
148
|
+
|
148
149
|
if !ipa_file_upload.nil? && File.extname(ipa_file_upload).eql?(".app")
|
149
150
|
mac_app_path = ipa_file_upload
|
150
151
|
ipa_base_dir = File.dirname(ipa_file_upload)
|
@@ -165,6 +166,7 @@ module Pindo
|
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
169
|
+
|
168
170
|
unless !ipa_file_upload.nil? && File.exist?(ipa_file_upload)
|
169
171
|
return
|
170
172
|
end
|
@@ -172,42 +174,9 @@ module Pindo
|
|
172
174
|
args_ipa_file_dir = File.expand_path(File::dirname(ipa_file_upload))
|
173
175
|
ipa_file_upload=File.join(args_ipa_file_dir, File.basename(ipa_file_upload))
|
174
176
|
current_project_dir = Dir.pwd
|
177
|
+
description = get_description_from_git(current_project_dir:current_project_dir)
|
178
|
+
description = " " if description.empty?
|
175
179
|
|
176
|
-
if description.nil? && is_git_directory?(local_repo_dir: current_project_dir)
|
177
|
-
current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
|
178
|
-
xcodeproj_file_name = Dir.glob(File.join(current_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
|
179
|
-
if !xcodeproj_file_name.nil? && !xcodeproj_file_name.empty? && File.exist?(xcodeproj_file_name)
|
180
|
-
project_obj = Xcodeproj::Project.open(xcodeproj_file_name)
|
181
|
-
main_target = project_obj.targets.select { |target| target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) }.first
|
182
|
-
provisioning_profile_name = main_target.build_configurations.first.build_settings['PROVISIONING_PROFILE_SPECIFIER'].downcase.split(" ")
|
183
|
-
if provisioning_profile_name.include?("adhoc")
|
184
|
-
description = git!(%W(-C #{current_project_dir} show -s --format=commit::%H)).strip
|
185
|
-
elsif provisioning_profile_name.include?("development")
|
186
|
-
cliff_toml_path = File.join(current_git_root_path, "cliff.toml")
|
187
|
-
if File.exist?(cliff_toml_path)
|
188
|
-
begin
|
189
|
-
`git-cliff --version`
|
190
|
-
git_cliff_installed = $?.success?
|
191
|
-
if git_cliff_installed
|
192
|
-
temp_dir = Dir.pwd
|
193
|
-
Dir.chdir(current_git_root_path)
|
194
|
-
description = `git-cliff -c #{cliff_toml_path} --latest -o -`.strip
|
195
|
-
description = " " if description.empty?
|
196
|
-
Dir.chdir(temp_dir)
|
197
|
-
else
|
198
|
-
description = " "
|
199
|
-
end
|
200
|
-
rescue StandardError => e
|
201
|
-
description = " "
|
202
|
-
end
|
203
|
-
else
|
204
|
-
description = " "
|
205
|
-
end
|
206
|
-
elsif provisioning_profile_name.include?("appstore")
|
207
|
-
description = "提交包重签名"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
180
|
|
212
181
|
addtach_file = nil
|
213
182
|
if ipa_file_upload.include?(File.join(current_project_dir, "build")) && File.exist?(File.join(current_project_dir, "VMData"))
|
@@ -551,50 +520,50 @@ module Pindo
|
|
551
520
|
end
|
552
521
|
|
553
522
|
|
554
|
-
def
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
523
|
+
def get_description_from_git(current_project_dir:nil)
|
524
|
+
description = nil
|
525
|
+
if !current_project_dir.nil? && is_git_directory?(local_repo_dir: current_project_dir)
|
526
|
+
current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
|
527
|
+
|
528
|
+
# dev 打包情况的备注
|
529
|
+
cliff_toml_path = File.join(current_git_root_path, "cliff.toml")
|
530
|
+
if File.exist?(cliff_toml_path)
|
531
|
+
begin
|
532
|
+
`git-cliff --version`
|
533
|
+
git_cliff_installed = $?.success?
|
534
|
+
if git_cliff_installed
|
535
|
+
temp_dir = Dir.pwd
|
536
|
+
Dir.chdir(current_git_root_path)
|
537
|
+
description = `git-cliff -c #{cliff_toml_path} --latest -o -`.strip
|
538
|
+
Dir.chdir(temp_dir)
|
539
|
+
end
|
540
|
+
rescue StandardError => e
|
541
|
+
end
|
542
|
+
end
|
564
543
|
end
|
565
|
-
|
566
|
-
puts "输入结束,输入内容为:"
|
567
|
-
puts "================================="
|
568
|
-
comment_str = comment_array.join("\n")
|
569
|
-
puts comment_array
|
570
|
-
puts "================================="
|
571
|
-
return comment_str
|
544
|
+
return description
|
572
545
|
end
|
573
546
|
|
574
547
|
def modify_coment(app_info_obj:nil, version_item_obj:nil)
|
575
548
|
|
576
|
-
|
577
|
-
|
578
|
-
puts "
|
579
|
-
puts
|
580
|
-
puts "================================="
|
581
|
-
puts "App: #{app_info_obj["appName"]}"
|
582
|
-
puts "版本: #{version_item_obj["appVersion"]} (build #{version_item_obj["build"]})"
|
583
|
-
puts "Build号: #{version_item_obj["incId"]}"
|
584
|
-
puts "bundleId: #{version_item_obj["bundleId"]}"
|
585
|
-
puts "上传时间: #{version_item_obj["updateTime"]}"
|
549
|
+
current_project_dir = Dir.pwd
|
550
|
+
comment_str = get_description_from_git(current_project_dir:current_project_dir)
|
551
|
+
puts "=========================================="
|
586
552
|
puts
|
587
|
-
puts "
|
553
|
+
puts "#{comment_str}"
|
588
554
|
puts
|
589
|
-
puts "
|
590
|
-
puts "================================="
|
555
|
+
puts "=========================================="
|
591
556
|
puts
|
592
|
-
|
593
|
-
|
594
|
-
|
557
|
+
|
558
|
+
if comment_str.nil? || comment_str.empty?
|
559
|
+
Funlog.instance.fancyinfo_error("没有找到git备注信息,无法修改pgyer备注!")
|
560
|
+
else
|
561
|
+
Funlog.instance.fancyinfo_start("开始修复pgyer备注...")
|
562
|
+
@pgyer_client.post_update_upload_comment(appId:app_info_obj["appId"], id:version_item_obj["id"], comment:comment_str.strip)
|
563
|
+
Funlog.instance.fancyinfo_start("pgyer备注已经修改!")
|
595
564
|
end
|
596
565
|
|
597
|
-
|
566
|
+
|
598
567
|
|
599
568
|
puts "备注信息修改成功!!"
|
600
569
|
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pindo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.9.
|
4
|
+
version: 4.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wade
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-21 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: claide
|
@@ -240,7 +240,6 @@ files:
|
|
240
240
|
- lib/pindo/client/pgyerclient.rb
|
241
241
|
- lib/pindo/client/pgyeruploadclient.rb
|
242
242
|
- lib/pindo/client/tgateclient.rb
|
243
|
-
- lib/pindo/client/unityhelper.rb
|
244
243
|
- lib/pindo/command.rb
|
245
244
|
- lib/pindo/command/android.rb
|
246
245
|
- lib/pindo/command/android/debug.rb
|
@@ -284,7 +283,7 @@ files:
|
|
284
283
|
- lib/pindo/command/dev/createbuild.rb
|
285
284
|
- lib/pindo/command/dev/debug.rb
|
286
285
|
- lib/pindo/command/dev/pgyercert.rb
|
287
|
-
- lib/pindo/command/dev/
|
286
|
+
- lib/pindo/command/dev/tag.rb
|
288
287
|
- lib/pindo/command/env.rb
|
289
288
|
- lib/pindo/command/env/dreamstudio.rb
|
290
289
|
- lib/pindo/command/env/quarkenv.rb
|
@@ -346,8 +345,10 @@ files:
|
|
346
345
|
- lib/pindo/module/appstore/appstore_metadata_connect_api_helper.rb
|
347
346
|
- lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb
|
348
347
|
- lib/pindo/module/appstore/iap_tier.json
|
348
|
+
- lib/pindo/module/build/buildhelper.rb
|
349
349
|
- lib/pindo/module/build/commonconfuseproj.rb
|
350
350
|
- lib/pindo/module/build/swarkhelper.rb
|
351
|
+
- lib/pindo/module/build/unityhelper.rb
|
351
352
|
- lib/pindo/module/cert/certhelper.rb
|
352
353
|
- lib/pindo/module/cert/keychainhelper.rb
|
353
354
|
- lib/pindo/module/cert/pemhelper.rb
|
@@ -1,171 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Pindo
|
4
|
-
class Command
|
5
|
-
class Dev < Command
|
6
|
-
class Pub < Dev
|
7
|
-
|
8
|
-
self.summary = '发布代码,添加tag,添加发布信息,并合并到发布分支'
|
9
|
-
|
10
|
-
self.description = <<-DESC
|
11
|
-
发布代码,添加tag,添加发布信息,并合并到发布分支。用法:在当前代码仓库下执行pindo dev pub
|
12
|
-
DESC
|
13
|
-
|
14
|
-
self.arguments = [
|
15
|
-
|
16
|
-
]
|
17
|
-
|
18
|
-
def self.options
|
19
|
-
[
|
20
|
-
].concat(super)
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(argv)
|
24
|
-
|
25
|
-
super
|
26
|
-
@additional_args = argv.remainder!
|
27
|
-
end
|
28
|
-
|
29
|
-
def run
|
30
|
-
|
31
|
-
release_branch = "master"
|
32
|
-
current_project_dir = Dir.pwd
|
33
|
-
|
34
|
-
process_need_add_files(project_dir:current_project_dir)
|
35
|
-
|
36
|
-
answer = agree("是否添加发布备注信息?(Y/n)")
|
37
|
-
if answer
|
38
|
-
add_release_info(project_dir:current_project_dir)
|
39
|
-
end
|
40
|
-
|
41
|
-
answer = agree("是否将代码合并到master分支?(Y/n)")
|
42
|
-
|
43
|
-
if answer
|
44
|
-
current_branch = git!(%W(-C #{current_project_dir} rev-parse --abbrev-ref HEAD)).strip
|
45
|
-
coding_branch = current_branch
|
46
|
-
merge_to_release_branch(project_dir:current_project_dir, release_branch:release_branch, coding_branch:coding_branch)
|
47
|
-
add_release_tag(project_dir:current_project_dir)
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def add_release_info(project_dir:nil)
|
54
|
-
|
55
|
-
puts
|
56
|
-
puts "输入Release 备注:"
|
57
|
-
description = PgyerHelper.share_instace.get_description()
|
58
|
-
File.open("#{project_dir}/.release_info", 'w') { |f| f.write(description) }
|
59
|
-
git_addpush_repo(path:project_dir, message:"update release info", commit_file_params:[".release_info"])
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def add_release_tag(project_dir:nil)
|
64
|
-
|
65
|
-
time_str = Time.now.strftime('%Y_%m_%d')
|
66
|
-
tag_name = "dev_" + time_str
|
67
|
-
remove_tag(local_repo_dir:project_dir, tag_name:tag_name)
|
68
|
-
result = add_tag(local_repo_dir:project_dir, tag_name:tag_name)
|
69
|
-
|
70
|
-
puts
|
71
|
-
puts "已经为当前仓库添加tag: #{tag_name}"
|
72
|
-
puts "仓库路径:#{project_dir}"
|
73
|
-
puts
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
def merge_to_release_branch(project_dir:nil, release_branch:nil, coding_branch:nil)
|
79
|
-
|
80
|
-
current_project_dir = project_dir
|
81
|
-
|
82
|
-
|
83
|
-
if !coding_branch.eql?(release_branch)
|
84
|
-
|
85
|
-
coding_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{coding_branch})).strip
|
86
|
-
release_branch_commit_id = "111"
|
87
|
-
|
88
|
-
if remote_branch_exists?(local_repo_dir: current_project_dir, branch:release_branch)
|
89
|
-
if local_branch_exists?(local_repo_dir: current_project_dir, branch:release_branch)
|
90
|
-
puts "存在#{release_branch}远程分支"
|
91
|
-
puts "存在#{release_branch}本地分支"
|
92
|
-
git!(%W(-C #{current_project_dir} checkout #{release_branch}))
|
93
|
-
else
|
94
|
-
puts "存在#{release_branch}远程分支"
|
95
|
-
puts "不存在#{release_branch}本地分支"
|
96
|
-
git!(%W(-C #{current_project_dir} checkout -b #{release_branch} origin/#{release_branch}))
|
97
|
-
end
|
98
|
-
|
99
|
-
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
|
100
|
-
git!(%W(-C #{current_project_dir} pull))
|
101
|
-
# git!(%W(-C #{current_project_dir} merge #{coding_branch} --quiet))
|
102
|
-
res_data = Executable.capture_command('git', %W(merge #{coding_branch}), :capture => :out)
|
103
|
-
|
104
|
-
conflict_filelist = git!(%W(-C #{current_project_dir} diff --name-only --diff-filter=U --relative))
|
105
|
-
if !conflict_filelist.nil? && conflict_filelist.size > 0
|
106
|
-
puts "合并代码冲突, 冲突文件如下:"
|
107
|
-
|
108
|
-
raise Informative, "请手动处理冲突的文件!!!"
|
109
|
-
|
110
|
-
else
|
111
|
-
git!(%W(-C #{current_project_dir} push))
|
112
|
-
|
113
|
-
|
114
|
-
puts ""
|
115
|
-
puts "===================================="
|
116
|
-
puts "代码已经合并到#{release_branch}分支"
|
117
|
-
puts "===================================="
|
118
|
-
puts ""
|
119
|
-
release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
|
120
|
-
end
|
121
|
-
|
122
|
-
else
|
123
|
-
if local_branch_exists?(local_repo_dir: current_project_dir, branch:release_branch)
|
124
|
-
puts "不存在#{release_branch}远程分支"
|
125
|
-
puts "存在#{release_branch}本地分支"
|
126
|
-
git!(%W(-C #{current_project_dir} checkout #{release_branch}))
|
127
|
-
git!(%W(-C #{current_project_dir} checkout -b #{release_branch}_temp))
|
128
|
-
git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
|
129
|
-
git!(%W(-C #{current_project_dir} branch -D #{release_branch}))
|
130
|
-
else
|
131
|
-
puts "不存在#{release_branch}远程分支"
|
132
|
-
puts "不存在#{release_branch}本地分支"
|
133
|
-
end
|
134
|
-
|
135
|
-
git!(%W(-C #{current_project_dir} checkout -b #{release_branch}))
|
136
|
-
git!(%W(-C #{current_project_dir} push origin #{release_branch}))
|
137
|
-
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
|
138
|
-
|
139
|
-
|
140
|
-
puts ""
|
141
|
-
puts "===================================="
|
142
|
-
puts "代码已经合并到#{release_branch}分支"
|
143
|
-
puts "===================================="
|
144
|
-
puts ""
|
145
|
-
release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
|
150
|
-
if !release_branch_commit_id.eql?(coding_branch_commit_id)
|
151
|
-
git!(%W(-C #{current_project_dir} merge #{release_branch}))
|
152
|
-
puts
|
153
|
-
puts "已将#{release_branch}合并到#{coding_branch}"
|
154
|
-
puts
|
155
|
-
end
|
156
|
-
|
157
|
-
else
|
158
|
-
puts ""
|
159
|
-
puts "===================================="
|
160
|
-
puts "代码处于#{coding_branch}分支,无需合并"
|
161
|
-
puts "===================================="
|
162
|
-
puts ""
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|