rlt 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rlt/cli.rb +1 -0
- data/lib/rlt/commands/cmt.rb +18 -0
- data/lib/rlt/commands/rst.rb +11 -0
- data/lib/rlt/config.rb +14 -4
- data/lib/rlt/utils/git_util.rb +19 -12
- data/lib/rlt/utils/shell.rb +1 -1
- data/lib/rlt/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 294c220cc2dee9c6f061133ed9f650c6571a4bbc
|
4
|
+
data.tar.gz: b7d2fdbf841d7ccd869d0e71d5ab41e44c2fcc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabcfa9a794d57858e5bd403830de86af1a5135e3c3d5dc6a7ae68cbda437347587998d0c24724a83559c4a6263212c315e61d84e9a138982fb4c47c68e41004
|
7
|
+
data.tar.gz: 195171058600ae6638532f09327f0966b9f79c28ff0035641b0c1ec7a8ddc672091037da1ea2d5a943d91290e33d1650e41f9590a498d60e45df0f2244252fb6
|
data/lib/rlt/cli.rb
CHANGED
data/lib/rlt/commands/cmt.rb
CHANGED
@@ -9,8 +9,26 @@ module Rlt
|
|
9
9
|
class Cmt
|
10
10
|
CONF_SUBJECT_TEMPLATE = 'subject_template'
|
11
11
|
CONF_BODY_TEMPLATE = 'body_template'
|
12
|
+
CONF_PRE = 'pre'
|
12
13
|
|
13
14
|
def self.run(config, add_all)
|
15
|
+
result = run_pre_script_if_any(config)
|
16
|
+
return print_abort_due_to_pre_script_failure unless result
|
17
|
+
ask_and_commit(add_all, config)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.print_abort_due_to_pre_script_failure
|
21
|
+
Utils::Logger.error 'Aborted due to the pre-script failed.'
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run_pre_script_if_any(config)
|
25
|
+
return true if config[CONF_PRE].nil?
|
26
|
+
Utils::Logger.info 'Executing pre-script:'
|
27
|
+
Utils::Logger.desc " #{config[CONF_PRE]}"
|
28
|
+
Utils::Shell.new.run_safely config[CONF_PRE]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.ask_and_commit(add_all, config)
|
14
32
|
branch_name = Utils::GitUtil.current_branch_name
|
15
33
|
Utils::Logger.info "Committing to '#{branch_name}'"
|
16
34
|
(subject, body) = subject_and_body(config, branch_name)
|
data/lib/rlt/config.rb
CHANGED
@@ -21,20 +21,30 @@ module Rlt
|
|
21
21
|
c.keys
|
22
22
|
end
|
23
23
|
|
24
|
-
def load_config
|
25
|
-
YAML.load_file(
|
24
|
+
def load_config(path)
|
25
|
+
result = YAML.load_file(path)
|
26
|
+
return result if result.is_a? Hash
|
27
|
+
{}
|
26
28
|
rescue Errno::ENOENT
|
27
29
|
{}
|
28
30
|
end
|
29
31
|
|
30
|
-
def
|
32
|
+
def local_config_path
|
31
33
|
sample_config_path = "#{Dir.pwd}/.rlt.sample.yml"
|
32
34
|
return sample_config_path if Rlt.debug && File.exist?(sample_config_path)
|
33
35
|
"#{Dir.pwd}/.rlt.yml"
|
34
36
|
end
|
35
37
|
|
38
|
+
def global_config_path
|
39
|
+
File.expand_path('~/.rlt.yml')
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_all_configs
|
43
|
+
load_config(global_config_path).merge(load_config(local_config_path))
|
44
|
+
end
|
45
|
+
|
36
46
|
def config_map
|
37
|
-
(@config_map ||=
|
47
|
+
(@config_map ||= load_all_configs)
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
data/lib/rlt/utils/git_util.rb
CHANGED
@@ -34,7 +34,7 @@ module Rlt
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.add_all
|
37
|
-
Shell.new.run 'git
|
37
|
+
Shell.new.run 'git add -A'
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.uncommitted_change?
|
@@ -51,44 +51,43 @@ module Rlt
|
|
51
51
|
|
52
52
|
def self.save_stash(message, opts = {})
|
53
53
|
Logger.info 'Saving stash' if opts[:print_info]
|
54
|
-
Shell.new.run 'git
|
54
|
+
Shell.new.run 'git stash save', '--include-untracked', message
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.apply_stash(name, opts = {})
|
58
58
|
Logger.info 'Applied stash' if opts[:print_info]
|
59
|
-
Shell.new.run 'git
|
59
|
+
Shell.new.run 'git stash apply', name, '--index'
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.drop_stash(name, opts = {})
|
63
63
|
Logger.info 'Dropped stash' if opts[:print_info]
|
64
|
-
Shell.new.run 'git
|
64
|
+
Shell.new.run 'git stash drop', name
|
65
65
|
end
|
66
66
|
|
67
67
|
def self.checkout(branch_name, opts = {})
|
68
68
|
Logger.info "Switching to `#{branch_name}`" if opts[:print_info]
|
69
|
-
Shell.new.run 'git
|
69
|
+
Shell.new.run 'git checkout', branch_name
|
70
70
|
end
|
71
71
|
|
72
72
|
def self.silently_try_checkout(branch_name)
|
73
|
-
|
74
|
-
result.success?
|
73
|
+
Shell.new(no_output: true).run_safely 'git checkout', branch_name
|
75
74
|
end
|
76
75
|
|
77
76
|
def self.silently_create_and_checkout(branch_name)
|
78
|
-
Shell.new(no_output: true).run 'git
|
77
|
+
Shell.new(no_output: true).run 'git checkout -b', branch_name
|
79
78
|
end
|
80
79
|
|
81
80
|
def self.commit_with_long_message(message)
|
82
81
|
Logger.verbose message if Rlt.debug
|
83
82
|
commit_msg_file_path = "#{Dir.tmpdir}/.rlt.commit.msg.#{StringUtil.short_random_string}"
|
84
83
|
File.write(commit_msg_file_path, message)
|
85
|
-
Shell.new.run 'git
|
84
|
+
Shell.new.run 'git commit -F', commit_msg_file_path
|
86
85
|
File.delete(commit_msg_file_path)
|
87
86
|
end
|
88
87
|
|
89
88
|
def self.merge_from(branch_name, opts = {})
|
90
89
|
Logger.info "Merging from `#{branch_name}`" if opts[:print_info]
|
91
|
-
Shell.new.run 'git
|
90
|
+
Shell.new.run 'git merge', branch_name
|
92
91
|
end
|
93
92
|
|
94
93
|
def self.any_conflict?
|
@@ -97,7 +96,7 @@ module Rlt
|
|
97
96
|
|
98
97
|
def self.delete_branch(branch_name, opts = {})
|
99
98
|
Logger.info "Deleting `#{branch_name}`" if opts[:print_info]
|
100
|
-
Shell.new.run 'git
|
99
|
+
Shell.new.run 'git branch -d', branch_name
|
101
100
|
end
|
102
101
|
|
103
102
|
def self.remotes
|
@@ -106,7 +105,15 @@ module Rlt
|
|
106
105
|
|
107
106
|
def self.safely_delete_remote_branch(remote, branch_name, opts = {})
|
108
107
|
Logger.info "Try deleting remote branch: #{remote}/#{branch_name}" if opts[:print_info]
|
109
|
-
Shell.new.run_safely 'git
|
108
|
+
Shell.new.run_safely 'git push', remote, ":#{branch_name}"
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.reset_hard_head
|
112
|
+
Shell.new.run 'git reset --hard HEAD'
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.clean_untracked
|
116
|
+
Shell.new.run 'git clean -fd'
|
110
117
|
end
|
111
118
|
end
|
112
119
|
end
|
data/lib/rlt/utils/shell.rb
CHANGED
data/lib/rlt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eunjae Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/rlt/cli.rb
|
137
137
|
- lib/rlt/commands/close.rb
|
138
138
|
- lib/rlt/commands/cmt.rb
|
139
|
+
- lib/rlt/commands/rst.rb
|
139
140
|
- lib/rlt/commands/switch.rb
|
140
141
|
- lib/rlt/config.rb
|
141
142
|
- lib/rlt/debug.rb
|