pindo 4.8.9 → 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 +54 -18
- 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 +39 -77
- 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
|
@@ -48,7 +48,9 @@ module Pindo
|
|
48
48
|
[
|
49
49
|
['--proj', '指定上传到测试平台的项目名称'],
|
50
50
|
['--upload', '上传编译后的IPA到测试平台'],
|
51
|
-
['--send', '上传成功后发送测试通知']
|
51
|
+
['--send', '上传成功后发送测试通知'],
|
52
|
+
['--base', 'Unity工程编译lib模式'],
|
53
|
+
['--unity-version', '切换Unity版本']
|
52
54
|
].concat(super)
|
53
55
|
end
|
54
56
|
|
@@ -59,6 +61,9 @@ module Pindo
|
|
59
61
|
@args_upload_flag = argv.flag?('upload', false)
|
60
62
|
@args_send_flag = argv.flag?('send', false)
|
61
63
|
@args_deploy_flag = argv.flag?('deploy', false)
|
64
|
+
@args_base_flag = argv.flag?('base', false)
|
65
|
+
@force_select_unity = argv.flag?('unity-version', false)
|
66
|
+
|
62
67
|
|
63
68
|
if @args_send_flag
|
64
69
|
@args_upload_flag = true
|
@@ -67,16 +72,16 @@ module Pindo
|
|
67
72
|
super
|
68
73
|
end
|
69
74
|
|
70
|
-
def export_ios_project(project_path)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
'platform' => 'iOS'
|
78
|
-
}
|
75
|
+
def export_ios_project(project_path, pindo_ios_project_dir, additional_args)
|
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}"
|
79
82
|
|
83
|
+
begin
|
84
|
+
|
80
85
|
# 执行Unity命令
|
81
86
|
result = unity_helper.execute_unity_command(
|
82
87
|
project_path,
|
@@ -87,7 +92,7 @@ module Pindo
|
|
87
92
|
if result[:success]
|
88
93
|
puts "Unity iOS library build completed successfully"
|
89
94
|
puts "Unity version: #{result[:unity_version]}"
|
90
|
-
puts "Output:"
|
95
|
+
puts "Output: #{pindo_ios_project_dir}"
|
91
96
|
puts result[:stdout]
|
92
97
|
return true
|
93
98
|
else
|
@@ -107,6 +112,19 @@ module Pindo
|
|
107
112
|
|
108
113
|
|
109
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
|
110
128
|
|
111
129
|
app_info_obj = nil
|
112
130
|
if @args_upload_flag
|
@@ -122,15 +140,25 @@ module Pindo
|
|
122
140
|
mainapp_bundleid = get_selected_dev_bundleid()
|
123
141
|
end
|
124
142
|
|
125
|
-
|
126
|
-
|
127
|
-
|
143
|
+
|
144
|
+
pindo_ios_project_dir = File.join(pindo_unity_project_dir, "Platform/iOS")
|
145
|
+
# 准备额外的参数
|
146
|
+
additional_args = {
|
147
|
+
'platform' => 'iOS'
|
148
|
+
}
|
149
|
+
if @args_base_flag
|
150
|
+
pindo_ios_project_dir = File.join(pindo_unity_project_dir, "Platform/BaseiOS")
|
151
|
+
additional_args = {
|
152
|
+
'platform' => 'iOS',
|
153
|
+
'buildtype' => 'library'
|
154
|
+
}
|
155
|
+
end
|
128
156
|
|
129
|
-
|
130
|
-
args_temp = []
|
157
|
+
export_ios_project(pindo_unity_project_dir, pindo_ios_project_dir, additional_args)
|
131
158
|
|
159
|
+
args_temp = []
|
132
160
|
args_temp << "--bundleid=#{mainapp_bundleid}"
|
133
|
-
|
161
|
+
|
134
162
|
if @args_upload_flag
|
135
163
|
args_temp << "--proj=#{app_info_obj["appName"]}"
|
136
164
|
args_temp << "--upload"
|
@@ -138,10 +166,18 @@ module Pindo
|
|
138
166
|
if @args_send_flag
|
139
167
|
args_temp << "--send"
|
140
168
|
end
|
169
|
+
|
141
170
|
Dir.chdir(pindo_ios_project_dir)
|
171
|
+
if @args_base_flag
|
172
|
+
`chmod 777 #{pindo_ios_project_dir}`
|
173
|
+
else
|
174
|
+
`chmod 777 #{pindo_ios_project_dir}/Unity`
|
175
|
+
end
|
176
|
+
|
142
177
|
|
143
178
|
Pindo::Command::Ios::Debug::run(args_temp)
|
144
179
|
|
180
|
+
|
145
181
|
|
146
182
|
end
|
147
183
|
|