rlt 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rlt/commands/close.rb +17 -36
- data/lib/rlt/commands/switch.rb +1 -1
- data/lib/rlt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46295cd21589c55682d55c4ab969f516cda5777f
|
4
|
+
data.tar.gz: a8de2fa6b1ae7144b26e6fef5d51812ae0133568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb0c963875edba813177e4dc70b1337d3931097752dc815f1291492e26f36384240a88b2a20a763caa32ca8e3d13e854158830317383b2044b9e8407d7b15ea
|
7
|
+
data.tar.gz: f925443939063cc7a1b85f64b509deac9cdef6e1240fa16574d09ccccefc42b6279a5180384494d30b66a9ff95590670b3e6c0b8b18fd7d1da243fcc81027ae5
|
data/lib/rlt/commands/close.rb
CHANGED
@@ -4,22 +4,21 @@ module Rlt
|
|
4
4
|
module Commands
|
5
5
|
class Close
|
6
6
|
def self.run(config)
|
7
|
-
|
7
|
+
default_branch = default_branch(config)
|
8
8
|
current_branch_name = Utils::GitUtil.current_branch_name
|
9
|
-
return if should_stop?(
|
10
|
-
run_internal(current_branch_name,
|
9
|
+
return if should_stop?(default_branch)
|
10
|
+
run_internal(current_branch_name, default_branch)
|
11
11
|
Utils::Logger.info "Done closing `#{current_branch_name}`."
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.run_internal(current_branch_name,
|
15
|
-
merge_back_and_forth(current_branch_name,
|
14
|
+
def self.run_internal(current_branch_name, default_branch)
|
15
|
+
merge_back_and_forth(current_branch_name, default_branch)
|
16
16
|
delete_branch(current_branch_name)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.should_stop?(
|
19
|
+
def self.should_stop?(default_branch)
|
20
20
|
return true if uncommitted_changes?
|
21
|
-
return true if
|
22
|
-
return true if master_branch_now?(master_branch)
|
21
|
+
return true if default_branch_now?(default_branch)
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.uncommitted_changes?
|
@@ -28,26 +27,20 @@ module Rlt
|
|
28
27
|
result
|
29
28
|
end
|
30
29
|
|
31
|
-
def self.
|
32
|
-
result =
|
33
|
-
|
30
|
+
def self.default_branch_now?(default_branch)
|
31
|
+
result = Utils::GitUtil.current_branch_name == default_branch
|
32
|
+
print_default_branch_now_error(default_branch) if result
|
34
33
|
result
|
35
34
|
end
|
36
35
|
|
37
|
-
def self.
|
38
|
-
|
39
|
-
print_master_branch_now_error(master_branch) if result
|
40
|
-
result
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.master_branch(config)
|
44
|
-
config['master_branch']
|
36
|
+
def self.default_branch(config)
|
37
|
+
config['default_branch'] || 'master'
|
45
38
|
end
|
46
39
|
|
47
|
-
def self.merge_back_and_forth(current_branch_name,
|
48
|
-
Utils::GitUtil.merge_from(
|
40
|
+
def self.merge_back_and_forth(current_branch_name, default_branch)
|
41
|
+
Utils::GitUtil.merge_from(default_branch, print_info: true)
|
49
42
|
return if any_conflict?
|
50
|
-
Utils::GitUtil.checkout(
|
43
|
+
Utils::GitUtil.checkout(default_branch, print_info: true)
|
51
44
|
Utils::GitUtil.merge_from(current_branch_name, print_info: true)
|
52
45
|
end
|
53
46
|
|
@@ -62,20 +55,8 @@ module Rlt
|
|
62
55
|
Utils::Logger.error 'Commit them first!'
|
63
56
|
end
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
Utils::Logger.error 'You must explicitly configure name of master branch at `.rlt.yml`'
|
68
|
-
Utils::Logger.error 'For example,'
|
69
|
-
Utils::Logger.error ''
|
70
|
-
Utils::Logger.error '# .rlt.yml'
|
71
|
-
Utils::Logger.error 'command:'
|
72
|
-
Utils::Logger.error ' close:'
|
73
|
-
Utils::Logger.error ' master_branch: master'
|
74
|
-
end
|
75
|
-
# rubocop:enable Metrics/MethodLength
|
76
|
-
|
77
|
-
def self.print_master_branch_now_error(master_branch)
|
78
|
-
Utils::Logger.error "You cannot close `#{master_branch}`."
|
58
|
+
def self.print_default_branch_now_error(default_branch)
|
59
|
+
Utils::Logger.error "You cannot close `#{default_branch}`."
|
79
60
|
end
|
80
61
|
|
81
62
|
def self.print_conflict_error
|
data/lib/rlt/commands/switch.rb
CHANGED
data/lib/rlt/version.rb
CHANGED