podsorz 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +1 -7
- data/Note +3 -0
- data/lib/podsorz.rb +2 -0
- data/lib/podsorz/command/sync.rb +32 -0
- data/lib/podsorz/core/podfile_io.rb +0 -1
- data/lib/podsorz/core/pods_git_manager.rb +53 -9
- data/lib/podsorz/core/pods_git_operator.rb +185 -64
- data/lib/podsorz/util/git_operator.rb +164 -30
- data/lib/podsorz/version.rb +1 -1
- metadata +4 -4
- data/Podfile +0 -0
- data/PodsOrzConfig.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c960d70973147909a6a1898da3101b1655a2a08426a90ae9c39cfbb7a838ffcd
|
4
|
+
data.tar.gz: fa464fe262693347b34eef283f83200571376124b60039c69ded9f688daf6575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979c4ee2d0dbf7d788aa5a9cab14633850c0c7d36ce7297356f2919aa5fc620ce578b995d25cce96d28453b828f381271fadc0f6b1d993624a088d7520316ef9
|
7
|
+
data.tar.gz: 649d4d2148002e5cdcb7140ee9553946f50f9747adf7d8e5da9ac79845ed8ea973785c679b2afe5a9b93b6e97b78fecc7320c26d4d5b208d6a8ff28d17a597a8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
podsorz (0.0.
|
4
|
+
podsorz (0.0.2)
|
5
5
|
cocoapods
|
6
6
|
colorize
|
7
7
|
gli (~> 2.16)
|
@@ -80,7 +80,6 @@ GEM
|
|
80
80
|
nap (1.1.0)
|
81
81
|
netrc (0.11.0)
|
82
82
|
public_suffix (4.0.6)
|
83
|
-
rake (10.5.0)
|
84
83
|
ruby-macho (1.4.0)
|
85
84
|
thread_safe (0.3.6)
|
86
85
|
typhoeus (1.4.0)
|
@@ -98,12 +97,7 @@ PLATFORMS
|
|
98
97
|
ruby
|
99
98
|
|
100
99
|
DEPENDENCIES
|
101
|
-
bundler (~> 1.17)
|
102
|
-
cocoapods
|
103
|
-
colorize
|
104
|
-
gli (~> 2.16)
|
105
100
|
podsorz!
|
106
|
-
rake (~> 10.0)
|
107
101
|
|
108
102
|
BUNDLED WITH
|
109
103
|
1.17.2
|
data/lib/podsorz.rb
CHANGED
@@ -6,6 +6,7 @@ require "podsorz/command/switch"
|
|
6
6
|
require "podsorz/command/commit"
|
7
7
|
require "podsorz/command/publish"
|
8
8
|
require "podsorz/command/install"
|
9
|
+
require "podsorz/command/sync"
|
9
10
|
|
10
11
|
require 'gli'
|
11
12
|
|
@@ -28,6 +29,7 @@ module PodsOrz
|
|
28
29
|
commit_command()
|
29
30
|
publish_command()
|
30
31
|
install_command()
|
32
|
+
sync_command()
|
31
33
|
|
32
34
|
desc "Show podsorz version"
|
33
35
|
command :version do |version|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "podsorz/core/pods_detector"
|
2
|
+
require "podsorz/core/pods_git_manager"
|
3
|
+
|
4
|
+
module PodsOrz
|
5
|
+
def self.sync_command
|
6
|
+
desc "Sync current_branch latest code from origin/current_branch or --rebase=‘other_branch’ "
|
7
|
+
command :sync do |sync|
|
8
|
+
sync.flag [:r, :rebase], :desc => "set rebase command on 'other_branch' "
|
9
|
+
|
10
|
+
sync.example "podsorz sync", desc:"current_branch 'git pull --rebase' "
|
11
|
+
sync.example "podsorz sync -r release", desc:"1.current_branch 'git pull --rebase', 2.sync commit from release"
|
12
|
+
sync.example "podsorz sync --rebase=feature/xq_2.0.0", desc:"1.current_branch 'git pull --rebase', 2.sync commit from feature/xq_2.0.0"
|
13
|
+
|
14
|
+
sync.action do |global_options, options, args|
|
15
|
+
other_branch = options[:rebase]
|
16
|
+
other_branch = other_branch.to_s.strip.chomp
|
17
|
+
|
18
|
+
dir_path = global_options[:path]
|
19
|
+
|
20
|
+
detector = PodsOrz::PodsDetector.new(dir_path)
|
21
|
+
detector.start_detector()
|
22
|
+
|
23
|
+
git_manager = PodsOrz::PodsGitManager.new(dir_path)
|
24
|
+
is_same = git_manager.ensure_pods_branch()
|
25
|
+
exit() unless is_same
|
26
|
+
|
27
|
+
git_manager.cmd_sync_pod(other_branch)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -98,7 +98,7 @@ module PodsOrz
|
|
98
98
|
#Commit Command --
|
99
99
|
|
100
100
|
def pod_commit(is_push, is_notify)
|
101
|
-
|
101
|
+
is_commit_success = true
|
102
102
|
|
103
103
|
pods_list = @orzconfig_parse.fix_pod_list
|
104
104
|
pods_list.each {|pod|
|
@@ -108,11 +108,13 @@ module PodsOrz
|
|
108
108
|
@pods_git_operator.commit_local(pod)
|
109
109
|
|
110
110
|
if is_push
|
111
|
-
is_push_success = @pods_git_operator.commit_push(pod)
|
111
|
+
is_push_success = @pods_git_operator.commit_push(pod)
|
112
|
+
is_commit_success = false unless is_push_success
|
112
113
|
end
|
113
114
|
|
114
115
|
if is_notify && is_push_success
|
115
|
-
|
116
|
+
is_notify_success = @pods_git_operator.commit_notify(pod)
|
117
|
+
is_commit_success = false unless is_notify_success
|
116
118
|
end
|
117
119
|
end
|
118
120
|
|
@@ -120,7 +122,7 @@ module PodsOrz
|
|
120
122
|
Logger.separator
|
121
123
|
}
|
122
124
|
|
123
|
-
exit() unless
|
125
|
+
exit() unless is_commit_success
|
124
126
|
|
125
127
|
if is_push && is_notify
|
126
128
|
update_push_podfile_io
|
@@ -202,8 +204,8 @@ module PodsOrz
|
|
202
204
|
#2.Podspec versoin
|
203
205
|
increase_pods_version(newContent_pod_list)
|
204
206
|
|
205
|
-
#3.Merge into master
|
206
|
-
|
207
|
+
#3.Merge into master
|
208
|
+
publish_master_branch(newContent_pod_list)
|
207
209
|
|
208
210
|
#4.Tag
|
209
211
|
add_publish_tag(newContent_pod_list)
|
@@ -216,6 +218,9 @@ module PodsOrz
|
|
216
218
|
|
217
219
|
#6.Update Podfile_orz
|
218
220
|
update_publish_podfile_orz
|
221
|
+
|
222
|
+
#7.Merge into develop
|
223
|
+
publish_develop_branch(newContent_pod_list)
|
219
224
|
end
|
220
225
|
|
221
226
|
def filter_newContent_pods()
|
@@ -264,13 +269,30 @@ module PodsOrz
|
|
264
269
|
exit() unless is_increase_success
|
265
270
|
end
|
266
271
|
|
267
|
-
def
|
272
|
+
def publish_master_branch(pods_list)
|
268
273
|
is_publish_success = true
|
269
274
|
pods_list.each {|pod|
|
270
|
-
Logger.default("【#{pod}】start merge into master
|
275
|
+
Logger.default("【#{pod}】start merge into master ...\n")
|
271
276
|
|
272
277
|
command = Thread.new do
|
273
|
-
each_result = @pods_git_operator.publish_merge(pod)
|
278
|
+
each_result = @pods_git_operator.publish_merge(pod, "master")
|
279
|
+
is_publish_success = false unless each_result
|
280
|
+
end
|
281
|
+
|
282
|
+
command.join
|
283
|
+
Logger.separator
|
284
|
+
}
|
285
|
+
|
286
|
+
exit() unless is_publish_success
|
287
|
+
end
|
288
|
+
|
289
|
+
def publish_develop_branch(pods_list)
|
290
|
+
is_publish_success = true
|
291
|
+
pods_list.each {|pod|
|
292
|
+
Logger.default("【#{pod}】start merge into develop ...\n")
|
293
|
+
|
294
|
+
command = Thread.new do
|
295
|
+
each_result = @pods_git_operator.publish_merge(pod, "develop")
|
274
296
|
is_publish_success = false unless each_result
|
275
297
|
end
|
276
298
|
|
@@ -425,5 +447,27 @@ module PodsOrz
|
|
425
447
|
|
426
448
|
command.join
|
427
449
|
end
|
450
|
+
|
451
|
+
#Sync Command --
|
452
|
+
def cmd_sync_pod(rebase_branch)
|
453
|
+
is_sync_success = true
|
454
|
+
|
455
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
456
|
+
pods_list.each {|pod|
|
457
|
+
Logger.default("【#{pod}】 begin sync ...\n")
|
458
|
+
|
459
|
+
command = Thread.new do
|
460
|
+
each_result = @pods_git_operator.sync_pod(pod, rebase_branch)
|
461
|
+
is_sync_success = false unless each_result
|
462
|
+
end
|
463
|
+
|
464
|
+
command.join
|
465
|
+
Logger.separator
|
466
|
+
}
|
467
|
+
|
468
|
+
exit() unless is_sync_success
|
469
|
+
|
470
|
+
end
|
471
|
+
|
428
472
|
end
|
429
473
|
end
|
@@ -214,7 +214,7 @@ module PodsOrz
|
|
214
214
|
is_develop = current_branch.include? "develop"
|
215
215
|
is_release = current_branch.include? "release/"
|
216
216
|
if is_develop || is_release
|
217
|
-
Logger.error("【#{pod}】on branch: \'#{current_branch}\' forbidden local commit which will be reset hard by other operation.Please manual 'git checkout #{current_branch};git push' first")
|
217
|
+
Logger.error("【#{pod}】on branch: \'#{current_branch}\' forbidden local commit which will be ‘reset --hard’ by other operation.Please manual 'git checkout #{current_branch};git push' first")
|
218
218
|
is_ready = false
|
219
219
|
else
|
220
220
|
Logger.warning("【#{pod}】on branch: \'#{current_branch}\' has local commits that not push remote, please do not forget to push remote in future.")
|
@@ -296,35 +296,19 @@ module PodsOrz
|
|
296
296
|
|
297
297
|
has_remote_branch = @git_operator.has_remote_branch(pod_file_path, current_branch)
|
298
298
|
unless has_remote_branch
|
299
|
-
@git_operator.push_to_remote(pod_file_path, current_branch)
|
299
|
+
is_push_success = @git_operator.push_to_remote(pod_file_path, current_branch)
|
300
300
|
return is_push_success
|
301
301
|
end
|
302
302
|
|
303
|
+
is_pull_success = @git_operator.pull(pod_file_path, current_branch, false)
|
303
304
|
|
304
|
-
|
305
|
-
|
306
|
-
pull_cmd_list = []
|
307
|
-
pull_cmd_list << "cd #{pod_file_path}"
|
308
|
-
pull_cmd_list << "git fetch origin #{current_branch}"
|
309
|
-
pull_cmd_list << "git pull --no-ff --no-squash --no-edit"
|
310
|
-
pull_io_lines = []
|
311
|
-
IO.popen(pull_cmd_list.join(";")) do |io|
|
312
|
-
pull_io_lines = io.readlines
|
313
|
-
pull_io_lines.each do |line|
|
314
|
-
has_conflicts = true if line.include? "Merge conflict"
|
315
|
-
end
|
316
|
-
|
317
|
-
io.close
|
318
|
-
end
|
319
|
-
|
320
|
-
if has_conflicts
|
321
|
-
Logger.error("【#{pod}】 on branch: \"#{current_branch}\" Merge conflict, please manual fix conflicts.(fix conflicts and run \"git commit\")(use \"git merge --abort\" to abort the merge)")
|
322
|
-
is_push_success = false
|
305
|
+
if is_pull_success
|
306
|
+
is_push_success = @git_operator.push_to_remote(pod_file_path, current_branch)
|
323
307
|
else
|
324
|
-
|
308
|
+
is_push_success = false
|
325
309
|
end
|
326
310
|
|
327
|
-
|
311
|
+
is_push_success
|
328
312
|
end
|
329
313
|
|
330
314
|
def commit_notify(pod)
|
@@ -365,25 +349,10 @@ module PodsOrz
|
|
365
349
|
|
366
350
|
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
367
351
|
current_branch = self.current_pod_branch(pod)
|
368
|
-
|
369
352
|
is_push_success = true
|
370
|
-
|
371
|
-
|
372
|
-
rebase_cmd_list = []
|
373
|
-
rebase_cmd_list << "cd #{pod_file_path}"
|
374
|
-
rebase_cmd_list << "git fetch origin #{base_on_branch}"
|
375
|
-
rebase_cmd_list << "git rebase origin/#{base_on_branch}"
|
376
|
-
rebase_cmd_lines = []
|
377
|
-
IO.popen(rebase_cmd_list.join(";")) do |io|
|
378
|
-
rebase_cmd_lines = io.readlines
|
379
|
-
rebase_cmd_lines.each do |line|
|
380
|
-
has_conflicts = true if line.include? "Merge conflict"
|
381
|
-
end
|
382
|
-
|
383
|
-
io.close
|
384
|
-
end
|
353
|
+
is_rebase_success = @git_operator.rebase(pod_file_path, base_on_branch)
|
385
354
|
|
386
|
-
|
355
|
+
unless is_rebase_success
|
387
356
|
Logger.error("【#{pod}】 on branch: \"#{current_branch}\" Merge conflict, please manual fix conflicts.(fix conflicts and run \"git rebase --continue\")(use \"git rebase --abort\" to abort the merge)")
|
388
357
|
is_push_success = false
|
389
358
|
else
|
@@ -530,14 +499,12 @@ module PodsOrz
|
|
530
499
|
is_ready
|
531
500
|
end
|
532
501
|
|
533
|
-
def publish_merge(pod)
|
502
|
+
def publish_merge(pod, merge_into_branch)
|
534
503
|
is_merge_success = true
|
535
504
|
|
536
505
|
is_merge_success = is_publish_ready(pod)
|
537
506
|
return is_merge_success unless is_merge_success
|
538
507
|
|
539
|
-
double_check_alert(pod)
|
540
|
-
|
541
508
|
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
542
509
|
current_branch = self.current_pod_branch(pod)
|
543
510
|
|
@@ -546,33 +513,17 @@ module PodsOrz
|
|
546
513
|
fetch_cmd_list << "git fetch origin #{current_branch}"
|
547
514
|
fetch_cmd_list << "git reset --hard origin/#{current_branch}"
|
548
515
|
IO.popen(fetch_cmd_list.join(";")) do |io|
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
516
|
+
io.each do |line|
|
517
|
+
puts line
|
518
|
+
end
|
519
|
+
io.close
|
553
520
|
end
|
554
521
|
|
555
|
-
is_merge_success = publish_merge_branch(pod,
|
556
|
-
return is_merge_success unless is_merge_success
|
557
|
-
|
558
|
-
is_merge_success = publish_merge_branch(pod, "develop", current_branch)
|
522
|
+
is_merge_success = publish_merge_branch(pod, merge_into_branch, current_branch)
|
559
523
|
|
560
524
|
is_merge_success
|
561
525
|
end
|
562
526
|
|
563
|
-
def double_check_alert(pod)
|
564
|
-
Logger.warning("【#{pod}】 即将提交合并到主干分支,请再次确认无异常,选择输入:[continue / stop]")
|
565
|
-
force_fetch_input = gets
|
566
|
-
if force_fetch_input.downcase.include? "stop"
|
567
|
-
Logger.error("【#{pod}】中止,程序已停止")
|
568
|
-
exit()
|
569
|
-
end
|
570
|
-
|
571
|
-
unless force_fetch_input.downcase.include? "continue"
|
572
|
-
double_check_alert(pod)
|
573
|
-
end
|
574
|
-
end
|
575
|
-
|
576
527
|
def publish_merge_branch(pod, into_branch, from_branch)
|
577
528
|
is_merge_success = true
|
578
529
|
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
@@ -604,6 +555,7 @@ module PodsOrz
|
|
604
555
|
push_cmd_list = []
|
605
556
|
push_cmd_list << "cd #{pod_file_path}"
|
606
557
|
push_cmd_list << "git push -u origin #{into_branch}"
|
558
|
+
push_cmd_list << "git checkout #{from_branch}"
|
607
559
|
IO.popen(push_cmd_list.join(";")) do |io|
|
608
560
|
io.each do |line|
|
609
561
|
puts line
|
@@ -695,6 +647,175 @@ module PodsOrz
|
|
695
647
|
|
696
648
|
git_tag
|
697
649
|
end
|
650
|
+
|
651
|
+
#sync cmd
|
652
|
+
|
653
|
+
def sync_pod(pod, rebase_branch)
|
654
|
+
is_sync_success = true
|
655
|
+
|
656
|
+
is_ready = check_prepare_work(pod)
|
657
|
+
unless is_ready
|
658
|
+
is_sync_success = false
|
659
|
+
return is_sync_success
|
660
|
+
end
|
661
|
+
|
662
|
+
#pull
|
663
|
+
is_pull_success = sync_current_branch_pull(pod)
|
664
|
+
unless is_pull_success
|
665
|
+
is_sync_success = false
|
666
|
+
return is_sync_success
|
667
|
+
end
|
668
|
+
|
669
|
+
#rebase
|
670
|
+
rebase_branch = rebase_branch.strip.chomp
|
671
|
+
if rebase_branch.empty?
|
672
|
+
return is_check_success
|
673
|
+
end
|
674
|
+
|
675
|
+
is_prepare_rebase = sync_prepare_rebase(pod, rebase_branch)
|
676
|
+
unless is_prepare_rebase
|
677
|
+
is_sync_success = false
|
678
|
+
return is_sync_success
|
679
|
+
end
|
680
|
+
|
681
|
+
is_rebase_success = sync_rebase(pod, rebase_branch)
|
682
|
+
unless is_rebase_success
|
683
|
+
is_sync_success = false
|
684
|
+
return is_sync_success
|
685
|
+
end
|
686
|
+
|
687
|
+
is_sync_success
|
688
|
+
end
|
689
|
+
|
690
|
+
def sync_current_branch_pull(pod)
|
691
|
+
is_pull_success = true
|
692
|
+
|
693
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
694
|
+
current_branch = @git_operator.current_branch(pod_file_path)
|
695
|
+
|
696
|
+
has_remote_branch = @git_operator.has_remote_branch(pod_file_path, current_branch)
|
697
|
+
if has_remote_branch
|
698
|
+
is_pull_success = @git_operator.pull(pod_file_path, current_branch, false)
|
699
|
+
end
|
700
|
+
|
701
|
+
is_pull_success
|
702
|
+
end
|
703
|
+
|
704
|
+
def sync_prepare_rebase(pod, rebase_branch)
|
705
|
+
is_check_success = true
|
706
|
+
|
707
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
708
|
+
has_branch = @git_operator.has_branch(pod_file_path, rebase_branch)
|
709
|
+
unless has_branch
|
710
|
+
Logger.error("branch '#{rebase_branch}' is not exist")
|
711
|
+
is_check_success = false
|
712
|
+
return is_check_success
|
713
|
+
end
|
714
|
+
|
715
|
+
is_check_success
|
716
|
+
end
|
717
|
+
|
718
|
+
def sync_rebase(pod, rebase_branch)
|
719
|
+
is_rebase_success = true
|
720
|
+
|
721
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
722
|
+
current_branch = @git_operator.current_branch(pod_file_path)
|
723
|
+
|
724
|
+
is_rebase_branch_check = sync_rebase_branch_check(pod, rebase_branch)
|
725
|
+
unless is_rebase_branch_check
|
726
|
+
is_rebase_success = false
|
727
|
+
return is_rebase_success
|
728
|
+
end
|
729
|
+
|
730
|
+
#personal
|
731
|
+
is_rebase_success = sync_personal_rebase(pod, rebase_branch)
|
732
|
+
|
733
|
+
is_rebase_success
|
734
|
+
end
|
735
|
+
|
736
|
+
def sync_rebase_branch_check(pod, rebase_branch)
|
737
|
+
is_check_success = true
|
738
|
+
|
739
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
740
|
+
current_branch = @git_operator.current_branch(pod_file_path)
|
741
|
+
|
742
|
+
#1.except develop
|
743
|
+
cmp_result = current_branch.casecmp("develop")
|
744
|
+
if cmp_result == 0
|
745
|
+
Logger.error("CMD of sync which current_branch can't be 'develop','develop' not support --rebase")
|
746
|
+
is_check_success = false
|
747
|
+
return is_check_success
|
748
|
+
end
|
749
|
+
|
750
|
+
#2.except release rebase
|
751
|
+
is_current_release_branch = current_branch.include? "release"
|
752
|
+
if is_current_release_branch
|
753
|
+
Logger.error("CMD of sync which current_branch is '#{current_branch}','release' not support --rebase, switch 'bugfix' branch, 'podsorz sync --rebase=develop' instead")
|
754
|
+
is_check_success = false
|
755
|
+
return is_check_success
|
756
|
+
end
|
757
|
+
|
758
|
+
#3.except rebase myself
|
759
|
+
cmp_result = current_branch.casecmp(rebase_branch)
|
760
|
+
if cmp_result == 0
|
761
|
+
Logger.error("CMD of sync which current_branch :#{current_branch} can't --rebase itself ")
|
762
|
+
is_check_success = false
|
763
|
+
return is_check_success
|
764
|
+
end
|
765
|
+
|
766
|
+
is_check_success
|
767
|
+
end
|
768
|
+
|
769
|
+
def sync_personal_rebase(pod, rebase_branch)
|
770
|
+
is_rebase_success = true
|
771
|
+
|
772
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
773
|
+
current_branch = @git_operator.current_branch(pod_file_path)
|
774
|
+
|
775
|
+
Logger.default("【#{pod}】 current_branch:#{current_branch} --rebase=#{rebase_branch} start...")
|
776
|
+
p_rebase_success = @git_operator.rebase(pod_file_path, rebase_branch)
|
777
|
+
|
778
|
+
unless p_rebase_success
|
779
|
+
is_rebase_success = false
|
780
|
+
Logger.warning("【#{pod}】--rebase=#{rebase_branch} 冲突,请手动解决冲突,并且进行后续强推个人分支操作('git push -f -u orogin #{current_branch}')。切勿反复调用 podsorz sync --rebase=#{rebase_branch} 带来未知情况的错误")
|
781
|
+
return is_rebase_success
|
782
|
+
end
|
783
|
+
|
784
|
+
#Personal branch diverged
|
785
|
+
has_div = @git_operator.has_diverged(pod_file_path)
|
786
|
+
if has_div
|
787
|
+
is_rebase_success = double_check_personal_rebase_fore_push(pod)
|
788
|
+
else
|
789
|
+
Logger.highlight("【#{pod}】 current_branch:#{current_branch} --rebase=#{rebase_branch} completed, use 'podsorz commit --push --notify' to push & notify updated code, or 'git reset commit' role back to old version")
|
790
|
+
end
|
791
|
+
|
792
|
+
is_rebase_success
|
793
|
+
end
|
794
|
+
|
795
|
+
def double_check_personal_rebase_fore_push(pod)
|
796
|
+
is_check_success = true
|
797
|
+
pod_file_path = File.expand_path(pod, @kx_pods_path)
|
798
|
+
current_branch = @git_operator.current_branch(pod_file_path)
|
799
|
+
|
800
|
+
Logger.warning("【#{pod}】本地分支:#{current_branch} rebase后与远端分支origin/#{current_branch}存在分叉,是否以本地分支'强推'覆盖远端分支,请选择输入:[force / wait]")
|
801
|
+
force_input = gets
|
802
|
+
if force_input.downcase.include? "wait"
|
803
|
+
Logger.warning("取消强推后,需要自行手动'git push -f'提交代码 or 'git reset commit'回退版本,请个人处理分支情况")
|
804
|
+
return is_check_success
|
805
|
+
end
|
806
|
+
|
807
|
+
unless force_input.downcase.include? "force"
|
808
|
+
is_check_success = double_check_personal_rebase_fore_push(pod)
|
809
|
+
return is_check_success
|
810
|
+
end
|
811
|
+
|
812
|
+
#push -f
|
813
|
+
is_check_success = @git_operator.push_personal_force_to_remote(pod_file_path, current_branch)
|
814
|
+
|
815
|
+
is_check_success
|
816
|
+
end
|
817
|
+
|
818
|
+
#class end
|
698
819
|
end
|
699
820
|
|
700
821
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "podsorz/util/logger"
|
2
2
|
|
3
3
|
module PodsOrz
|
4
4
|
class GitOperator
|
@@ -14,6 +14,8 @@ module PodsOrz
|
|
14
14
|
io.each do |line|
|
15
15
|
has_branch = true if line.include? branch_name
|
16
16
|
end
|
17
|
+
|
18
|
+
io.close
|
17
19
|
end
|
18
20
|
has_branch
|
19
21
|
end
|
@@ -24,6 +26,8 @@ module PodsOrz
|
|
24
26
|
io.each do |line|
|
25
27
|
has_branch = true if line.include? branch_name
|
26
28
|
end
|
29
|
+
|
30
|
+
io.close
|
27
31
|
end
|
28
32
|
has_branch
|
29
33
|
end
|
@@ -34,36 +38,28 @@ module PodsOrz
|
|
34
38
|
io.each do |line|
|
35
39
|
has_branch = true if line.include? branch_name
|
36
40
|
end
|
41
|
+
|
42
|
+
io.close
|
37
43
|
end
|
38
44
|
has_branch
|
39
45
|
end
|
40
46
|
|
41
47
|
def checkout(path, branch_name)
|
48
|
+
is_checkout_success = true
|
42
49
|
Dir.chdir(path) do
|
43
50
|
IO.popen("git checkout #{branch_name}") do |io|
|
44
51
|
io.each do |line|
|
45
|
-
|
52
|
+
if line.include? 'error'
|
53
|
+
Logger.error("Checkout #{branch_name} failed.")
|
54
|
+
is_checkout_success = false
|
55
|
+
end
|
46
56
|
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def fetch(path)
|
52
|
-
Dir.chdir(path) do
|
53
|
-
`git fetch origin`
|
54
|
-
end
|
55
|
-
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
`git rebase origin/#{branch_name}`
|
58
|
+
io.close
|
59
|
+
end
|
60
60
|
end
|
61
|
-
end
|
62
61
|
|
63
|
-
|
64
|
-
Dir.chdir(path) do
|
65
|
-
`git clone #{git_base}`
|
66
|
-
end
|
62
|
+
is_checkout_success
|
67
63
|
end
|
68
64
|
|
69
65
|
def commit(path, message)
|
@@ -74,15 +70,57 @@ module PodsOrz
|
|
74
70
|
end
|
75
71
|
|
76
72
|
def push_to_remote(path, branch_name)
|
77
|
-
|
78
|
-
|
73
|
+
is_push_success = true
|
74
|
+
|
75
|
+
push_lines = []
|
76
|
+
IO.popen("cd #{path};git push -u origin #{branch_name}") do |io|
|
77
|
+
push_lines = io.readlines
|
78
|
+
io.each do |line|
|
79
|
+
if line.include? "error"
|
80
|
+
is_push_success = false
|
81
|
+
end
|
82
|
+
|
83
|
+
if line.include? "fatal"
|
84
|
+
is_push_success = false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
io.close
|
89
|
+
end
|
90
|
+
|
91
|
+
unless is_push_success
|
92
|
+
Logger.error("#{branch_name} push to remote failed!")
|
93
|
+
push_lines.each do |line|
|
94
|
+
puts(line)
|
95
|
+
end
|
79
96
|
end
|
97
|
+
|
98
|
+
is_push_success
|
80
99
|
end
|
81
100
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
101
|
+
def push_personal_force_to_remote(path, branch_name)
|
102
|
+
is_push_success = true
|
103
|
+
|
104
|
+
push_lines = []
|
105
|
+
IO.popen("cd #{path};git push -u -f origin #{branch_name}") do |io|
|
106
|
+
push_lines = io.readlines
|
107
|
+
io.each do |line|
|
108
|
+
if line.include? "error"
|
109
|
+
is_push_success = false
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
io.close
|
114
|
+
end
|
115
|
+
|
116
|
+
unless is_push_success
|
117
|
+
Logger.error("#{branch_name} push to remote failed!")
|
118
|
+
push_lines.each do |line|
|
119
|
+
puts(line)
|
120
|
+
end
|
85
121
|
end
|
122
|
+
|
123
|
+
is_push_success
|
86
124
|
end
|
87
125
|
|
88
126
|
def has_commits(path, branch_name)
|
@@ -91,7 +129,10 @@ module PodsOrz
|
|
91
129
|
io.each do |line|
|
92
130
|
has_commits = true if line.include? "commit"
|
93
131
|
end
|
132
|
+
|
133
|
+
io.close
|
94
134
|
end
|
135
|
+
|
95
136
|
has_commits
|
96
137
|
end
|
97
138
|
|
@@ -102,7 +143,10 @@ module PodsOrz
|
|
102
143
|
io.each do |line|
|
103
144
|
has_changes = false if line.include? clear_flag
|
104
145
|
end
|
146
|
+
|
147
|
+
io.close
|
105
148
|
end
|
149
|
+
|
106
150
|
has_changes
|
107
151
|
end
|
108
152
|
|
@@ -141,7 +185,10 @@ module PodsOrz
|
|
141
185
|
io.each do |line|
|
142
186
|
tags << line
|
143
187
|
end
|
188
|
+
|
189
|
+
io.close
|
144
190
|
end
|
191
|
+
|
145
192
|
unless tags.include? "#{version}\n"
|
146
193
|
Dir.chdir(path) do
|
147
194
|
`git tag -a #{version} -m "release: V #{version}" master;`
|
@@ -149,6 +196,7 @@ module PodsOrz
|
|
149
196
|
end
|
150
197
|
return
|
151
198
|
end
|
199
|
+
|
152
200
|
Logger.highlight("tag already exists in the remote, skip this step")
|
153
201
|
end
|
154
202
|
|
@@ -158,7 +206,10 @@ module PodsOrz
|
|
158
206
|
io.each do |line|
|
159
207
|
tag_list << line
|
160
208
|
end
|
209
|
+
|
210
|
+
io.close
|
161
211
|
end
|
212
|
+
|
162
213
|
tag_list
|
163
214
|
end
|
164
215
|
|
@@ -168,7 +219,10 @@ module PodsOrz
|
|
168
219
|
io.each do |line|
|
169
220
|
unmerged_branch.push(line) if line.include? "#{condition}"
|
170
221
|
end
|
222
|
+
|
223
|
+
io.close
|
171
224
|
end
|
225
|
+
|
172
226
|
if (unmerged_branch.size > 0)
|
173
227
|
unmerged_branch.map { |item|
|
174
228
|
Logger.default(item)
|
@@ -177,12 +231,6 @@ module PodsOrz
|
|
177
231
|
end
|
178
232
|
end
|
179
233
|
|
180
|
-
def merge(path, branch_name)
|
181
|
-
IO.popen("cd '#{path}'; git merge #{branch_name}") do |line|
|
182
|
-
Logger.error("Merge conflict in #{branch_name}") if line.include? 'Merge conflict'
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
234
|
def compare_branch(path, branch, compare_branch)
|
187
235
|
diff_commit_list = []
|
188
236
|
|
@@ -195,14 +243,100 @@ module PodsOrz
|
|
195
243
|
diff_commit_list << line unless line.strip.chomp.empty?
|
196
244
|
end
|
197
245
|
|
246
|
+
io.close
|
198
247
|
end
|
199
248
|
|
200
249
|
diff_commit_list
|
201
250
|
end
|
202
251
|
|
252
|
+
def pull(path, branch, is_merge)
|
253
|
+
is_pull_success = true
|
254
|
+
has_conflicts = false
|
255
|
+
|
256
|
+
pull_cmd_list = []
|
257
|
+
pull_cmd_list << "cd #{path}"
|
258
|
+
pull_cmd_list << "git fetch origin #{branch}"
|
259
|
+
|
260
|
+
if is_merge
|
261
|
+
pull_cmd_list << "git pull --no-ff --no-squash --no-edit"
|
262
|
+
else
|
263
|
+
pull_cmd_list << "git pull --rebase"
|
264
|
+
end
|
265
|
+
|
266
|
+
pull_io_lines = []
|
267
|
+
IO.popen(pull_cmd_list.join(";")) do |io|
|
268
|
+
pull_io_lines = io.readlines
|
269
|
+
pull_io_lines.each do |line|
|
270
|
+
has_conflicts = true if line.include? "Merge conflict"
|
271
|
+
end
|
272
|
+
|
273
|
+
io.close
|
274
|
+
end
|
275
|
+
|
276
|
+
if has_conflicts
|
277
|
+
if is_merge
|
278
|
+
Logger.error("【#{path}】\n on branch: \"#{branch}\" (pull)Merge conflict, please manual fix conflicts.(fix conflicts and run \"git commit\")(use \"git merge --abort\" to abort the merge)")
|
279
|
+
else
|
280
|
+
Logger.error("【#{path}】\n on branch: \"#{branch}\" (pull)Rebase conflict, please manual fix conflicts.(fix conflicts and run \"git rebase --continue\")(use \"git rebase --abort\" to abort the merge)")
|
281
|
+
end
|
282
|
+
|
283
|
+
is_pull_success = false
|
284
|
+
end
|
285
|
+
|
286
|
+
is_pull_success
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
def rebase(path, branch)
|
291
|
+
is_rebase_success = true
|
292
|
+
|
293
|
+
is_remote_branch = has_remote_branch(path, branch)
|
294
|
+
|
295
|
+
rebase_cmd_list = []
|
296
|
+
rebase_cmd_list << "cd #{path}"
|
297
|
+
|
298
|
+
if is_remote_branch
|
299
|
+
rebase_cmd_list << "git fetch origin #{branch}"
|
300
|
+
rebase_cmd_list << "git rebase origin/#{branch}"
|
301
|
+
else
|
302
|
+
rebase_cmd_list << "git rebase #{branch}"
|
303
|
+
end
|
304
|
+
|
305
|
+
has_conflicts = false
|
306
|
+
rebase_cmd_lines = []
|
307
|
+
IO.popen(rebase_cmd_list.join(";")) do |io|
|
308
|
+
rebase_cmd_lines = io.readlines
|
309
|
+
rebase_cmd_lines.each do |line|
|
310
|
+
has_conflicts = true if line.include? "Merge conflict"
|
311
|
+
end
|
312
|
+
|
313
|
+
io.close
|
314
|
+
end
|
315
|
+
|
316
|
+
if has_conflicts
|
317
|
+
c_branch = current_branch(path)
|
318
|
+
Logger.error("【#{path}】\n on branch: \"#{c_branch}\" Merge conflict, please manual fix conflicts.(fix conflicts and run \"git rebase --continue\")(use \"git rebase --abort\" to abort the merge)")
|
319
|
+
is_rebase_success = false
|
320
|
+
end
|
321
|
+
|
322
|
+
is_rebase_success
|
323
|
+
end
|
203
324
|
|
325
|
+
def has_diverged(path)
|
326
|
+
has_div = false
|
327
|
+
IO.popen("cd #{path};git status") do |io|
|
328
|
+
rebase_cmd_lines = io.readlines
|
329
|
+
rebase_cmd_lines.each do |line|
|
330
|
+
has_div = true if line.include? "diverged"
|
331
|
+
end
|
204
332
|
|
333
|
+
io.close
|
334
|
+
end
|
335
|
+
|
336
|
+
has_div
|
337
|
+
end
|
205
338
|
|
339
|
+
#Class end
|
206
340
|
end
|
207
341
|
|
208
342
|
end
|
data/lib/podsorz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podsorz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiangqi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -65,8 +65,7 @@ files:
|
|
65
65
|
- Gemfile
|
66
66
|
- Gemfile.lock
|
67
67
|
- LICENSE.txt
|
68
|
-
-
|
69
|
-
- PodsOrzConfig.rb
|
68
|
+
- Note
|
70
69
|
- README.md
|
71
70
|
- Rakefile
|
72
71
|
- bin/podsorz
|
@@ -76,6 +75,7 @@ files:
|
|
76
75
|
- lib/podsorz/command/publish.rb
|
77
76
|
- lib/podsorz/command/setup.rb
|
78
77
|
- lib/podsorz/command/switch.rb
|
78
|
+
- lib/podsorz/command/sync.rb
|
79
79
|
- lib/podsorz/core/orz_config_templet.rb
|
80
80
|
- lib/podsorz/core/orz_env_detector.rb
|
81
81
|
- lib/podsorz/core/pod_orzconfig_parse.rb
|
data/Podfile
DELETED
File without changes
|