rlt 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b014aed42ee9f1d1b4ecd34949eeeda4f07806143b9c2323900db6d2acc8ef0d
4
- data.tar.gz: cc26f6909253057f325a877724eaa408100e725117c39bbfe55f683a619ffb68
3
+ metadata.gz: 7d5e0d5c96151a0109da828bea2aceefe7724ae31f1b48db2b857a8be57544fc
4
+ data.tar.gz: 4bb26123cb6654a975937707851fd789cabd0a6d70a6b53da1e088ea53ab7776
5
5
  SHA512:
6
- metadata.gz: 6ad76cec7c0bc731b7053aa47fd5136f6fc1f137945b15470d22ef62934e7ae9fe58a14892b54bde6d833a65fec6de0da4e1e059b15ec89fe5e19c08d0b6a590
7
- data.tar.gz: b448baa3c0f3d39b0e90962810498a57db78fe28549b06d2bc092ae752270efa44a7c0c196d8bf0be532883b5ff30922c2e5602ea7d696d4dbe96c273ffac0e3
6
+ metadata.gz: 212073d3b4b2acd1f826124fbf37d70ca267a019d1d0dd724d9ffdf2c5e0468b205d1b6a046f20a51ede74078eb9b8f97be15c2b835a21c80101025dd2970e98
7
+ data.tar.gz: '09018f8e6be388149a24971bcb84a6879d8ec57de64c161647aee08ee26ecf3082e7d8e926a0532e701ada21242540a09496d51addda4013a2f5e393d91e4bd1'
data/.rlt.sample.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  command:
2
2
  switch:
3
3
  branch_name_template: JIRA-<%= branch_name %>
4
+ exclude:
5
+ - some_branch
6
+ - some_other_branch
4
7
  cmt:
5
8
  subject_template: >
6
9
  <%=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rlt (0.1.2)
4
+ rlt (0.1.3)
5
5
  pastel (~> 0.7.2)
6
6
  tty-command (~> 0.8.0)
7
7
  tty-prompt (~> 0.16.1)
@@ -31,7 +31,7 @@ module Rlt
31
31
 
32
32
  def self.commit(subject, body)
33
33
  commit_msg_file_path = "#{Dir.tmpdir}/.rlt.commit.msg.#{short_random_string}"
34
- File.write(commit_msg_file_path, "#{subject}\n\n#{body}")
34
+ File.write(commit_msg_file_path, "#{subject}\n\n#{body}".strip)
35
35
  Shell.new.run 'git', 'commit', '-F', commit_msg_file_path
36
36
  File.delete(commit_msg_file_path)
37
37
  end
@@ -13,11 +13,17 @@ module Rlt
13
13
  end
14
14
 
15
15
  def self.change_branch_name(config, branch_name)
16
+ return branch_name if exclude?(config, branch_name)
16
17
  branch_name_template = config[CONF_BRANCH_NAME_TEMPLATE]
17
18
  return branch_name if branch_name_template.nil?
18
19
  ERB.new(branch_name_template).result binding
19
20
  end
20
21
 
22
+ def self.exclude?(config, branch_name)
23
+ list = %w[master develop] + (config['exclude'] || [])
24
+ list.include? branch_name
25
+ end
26
+
21
27
  def self.switch(branch_name)
22
28
  create_and_checkout(branch_name) if checkout(branch_name).failure?
23
29
  end
data/lib/rlt/config.rb CHANGED
@@ -5,23 +5,20 @@ require 'yaml'
5
5
  module Rlt
6
6
  module Config
7
7
  def config(category, command)
8
- category_config(category)[command] || category_config(category)[original(command)] || {}
9
- rescue NoMethodError
10
- {}
8
+ c = config_map.dig category, command
9
+ return c unless c.nil?
10
+ return {} if command == original_name(command)
11
+ config_map.dig(category, original_name(command)) || {}
11
12
  end
12
13
 
13
- def original(command)
14
- config('alias', command)
14
+ def original_name(command)
15
+ config_map.dig 'alias', command
15
16
  end
16
17
 
17
18
  def config_keys(category)
18
- category_config(category).keys
19
- rescue NoMethodError
20
- []
21
- end
22
-
23
- def category_config(category)
24
- (@config ||= load_config)[category]
19
+ c = config_map.dig(category)
20
+ return [] if c.nil?
21
+ c.keys
25
22
  end
26
23
 
27
24
  def load_config
@@ -37,5 +34,9 @@ module Rlt
37
34
  "#{Dir.pwd}/.rlt.yml"
38
35
  end
39
36
  end
37
+
38
+ def config_map
39
+ (@config_map ||= load_config)
40
+ end
40
41
  end
41
42
  end
data/lib/rlt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rlt
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rlt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Lee