branch-name 3.10.2 → 3.10.4

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: e6755eafad2f3cdbb8306f1dd8b05d4e1b2c7b464a0c5fc6f904ae8b52077757
4
- data.tar.gz: fec50285f0ed0906e20a043713c22bf8ce5be55e8d6d47f8aa175986e80e9e3b
3
+ metadata.gz: 8e4530135fd14912b126a23e3db17710d647c80b97b38b7320c3d93c385c16fb
4
+ data.tar.gz: d87d2863a7999bb093630e013c94959bfa2351947ac696be448e59d71853a5b0
5
5
  SHA512:
6
- metadata.gz: d2db88f7a2b2e353e24cd08c83c4fabf303280a3c7f3ac1378af719dc67a84804644f33f17bd10b36979024aaf770d65fb3bd61d7a52ca2e45c68f66af6630f9
7
- data.tar.gz: 17888dbb655be0cca5fcafdb5d006d3c54152d3bf3062d7b5626fbf5e259a22f2c32f330830c969984d2cb18303813f4d897256485fee31ae9578ceb0d978367
6
+ metadata.gz: 1641bc9f6cd8d9b98a0fd80d910af2c59f332dcd2df6d1bc87b8f2dbde98d9aedf810a4cdea0d53982789afd20a242c8ef5c7c7c7b3aa4911876f1872560cd4b
7
+ data.tar.gz: 858eb02458c7324a8c9020e7dd8dfe0236e6c865dee2c5577c35fdeb20feb5cde0c8ae4b70e09aa9368d7d6aa2e3581a92a29130d75a534f164e711cf69711e1
data/CHANGELOG.md CHANGED
@@ -1,86 +1,143 @@
1
+ ## ['3.10.4'] - 2023-11-01
2
+
3
+ Changes
4
+
5
+ - Update gems.
6
+
7
+ ## ['3.10.3'] - 2023-08-18
8
+
9
+ Changes
10
+
11
+ - Update gems.
12
+ - Various code refactors.
13
+ - Add some more test coverage.
14
+
1
15
  ## ['3.10.2'] - 2023-08-17
2
- * Changes
3
- * Update gems.
16
+
17
+ Changes
18
+
19
+ - Update gems.
4
20
 
5
21
  ## ['3.10.1'] - 2023-03-22
6
- * Changes
7
- * Update gems. Remedy an activesupport dependabot alert.
22
+
23
+ Changes
24
+
25
+ - Update gems. Remedy an activesupport dependabot alert.
8
26
 
9
27
  ## ['3.10.0'] - 2023-02-16
10
- * Changes
11
- * Update gems.
28
+
29
+ Changes
30
+
31
+ - Update gems.
12
32
 
13
33
  ## ['3.9.0'] - 2022-11-04
14
- * Changes
15
- * Update gems.
34
+
35
+ Changes
36
+
37
+ - Update gems.
16
38
 
17
39
  ## ['3.8.0'] - 2022-11-04
18
- * Changes
19
- * Limit gem version to ~> 3.0 to avoid breaking changes.
40
+
41
+ Changes
42
+
43
+ - Limit gem version to ~> 3.0 to avoid breaking changes.
20
44
 
21
45
  ## ['3.7.0'] - 2022-10-06
22
- * Changes
23
- * Use thor_nested_subcommand to fix Thor nested subcommand help bug.
24
- * Add missing global config option for create: :interactive.
46
+
47
+ Changes
48
+
49
+ - Use thor_nested_subcommand to fix Thor nested subcommand help bug.
50
+ - Add missing global config option for create: :interactive.
25
51
 
26
52
  ## ['3.6.0'] - 2022-10-06
27
- * Changes
28
- * Added a `-i` (interactive) option to `branch-name create`. When used in conjunction with the `-p` option (project creation), if the `-i` option is used, the user will be prompted to create the project. If the `-i` option is NOT used, the user will NOT be prompted when creating the project.
29
- * Update the README.md file accordign to the aforementioned.
53
+
54
+ Changes
55
+
56
+ - Added a `-i` (interactive) option to `branch-name create`. When used in conjunction with the `-p` option (project creation), if the `-i` option is used, the user will be prompted to create the project. If the `-i` option is NOT used, the user will NOT be prompted when creating the project.
57
+ - Update the README.md file accordign to the aforementioned.
30
58
 
31
59
  ## ['3.5.1'] - 2022-10-05
32
- * Bug Fixes
33
- * Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
34
- * Fix bug that allowed unacceptable project folder token separators in the project folder name (-p option). The rule is now: for `branch-name create`, if the `options[:separator]` option (-s) is included in `Branch::Name::Normalizable::PROJECT_FOLDER_TOKEN_SEPARATORS`, `options[:separator]` (-s) will be used as the project folder token separator; otherwise, `Branch::Name::Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR` will be used.
35
- * Changes
36
- * Add test coverage for the above scenarios.
37
- * Use File.join to join paths and files safely where appropriate.
38
- * Update .gemspec gem description with more detail.
60
+
61
+ Changes
62
+
63
+ - Add test coverage for the above scenarios.
64
+ - Use File.join to join paths and files safely where appropriate.
65
+ - Update .gemspec gem description with more detail.
66
+
67
+ Bug Fixes
68
+
69
+ - Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
70
+ - Fix bug that allowed unacceptable project folder token separators in the project folder name (-p option). The rule is now: for `branch-name create`, if the `options[:separator]` option (-s) is included in `Branch::Name::Normalizable::PROJECT_FOLDER_TOKEN_SEPARATORS`, `options[:separator]` (-s) will be used as the project folder token separator; otherwise, `Branch::Name::Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR` will be used.
39
71
 
40
72
  ## ['3.5.0'] - 2022-10-04
41
- * Changes
42
- * Fix broken link to CHANGELOG.md in .gemspec file.
73
+
74
+ Changes
75
+
76
+ - Fix broken link to CHANGELOG.md in .gemspec file.
43
77
 
44
78
  ## ['3.4.0'] - 2022-10-04
45
- * Changes
46
- * `branch-name create` when creating projects prompts to confirm creating of projects by clicking 'y'. This change was prompted because projects were being created when users were attempting to display help for `branch-name create`; for example, users were incorrectly attempting to display help using `branch-name create help`, when, infact, `branch-name help create` should have been entered. Incorrectly executing `branch-name create help` would create a project with the name "help". Prompting the user to verify project creation solves this problem.
47
- * Various changes in information printed to stdout when (for example) creating projects.
79
+
80
+ Changes
81
+
82
+ - `branch-name create` when creating projects prompts to confirm creating of projects by clicking 'y'. This change was prompted because projects were being created when users were attempting to display help for `branch-name create`; for example, users were incorrectly attempting to display help using `branch-name create help`, when, infact, `branch-name help create` should have been entered. Incorrectly executing `branch-name create help` would create a project with the name "help". Prompting the user to verify project creation solves this problem.
83
+ - Various changes in information printed to stdout when (for example) creating projects.
48
84
 
49
85
  ## ['3.3.0'] - 2022-09-27
50
- * Enhancements:
51
- * `branch-name config info` now displays the contents of both the Global and the local config files.
86
+
87
+ Enhancements
88
+
89
+ - `branch-name config info` now displays the contents of both the Global and the local config files.
52
90
 
53
91
  ## ['3.2.2'] - 2022-09-27
54
- * Changes:
55
- * Refactor code that patches Thor incorrect display of nested commands (subcommangs).
92
+
93
+ Changes
94
+
95
+ - Refactor code that patches Thor incorrect display of nested commands (subcommangs).
56
96
 
57
97
  ## ['3.2.1'] - 2022-09-27
58
- * Changes:
59
- * Fix rubocop violations.
60
- * Miscellaneous mixin refactors.
61
- * Bug Fixes: Fix bug that displayed subcommand help incorrectly.
98
+
99
+ Changes
100
+
101
+ - Fix rubocop violations.
102
+ - Miscellaneous mixin refactors.
103
+ - Bug Fixes: Fix bug that displayed subcommand help incorrectly.
62
104
 
63
105
  ## ['3.1.0'] - 2022-09-26
64
- * Enhancements:
65
- * Branch names may now be created using a forward-slash (/). See the README.md file for more information.
66
- * The `branch-name create :format_string` option string now accepts a %u placeholder which will be replaced with the currently logged in username. See `$ branch-name help create` for more information.
106
+
107
+ Enhancements
108
+
109
+ - Branch names may now be created using a forward-slash (/). See the README.md file for more information.
110
+ - The `branch-name create :format_string` option string now accepts a %u placeholder which will be replaced with the currently logged in username. See `$ branch-name help create` for more information.
67
111
 
68
112
  ## ['3.0.0'] - 2022-09-26
69
- * Changes:
70
- * Default default commands to :help.
71
- * Remove references to system for options, folder locations, etc. These were not being used and the nature of this tool is that global options should suffice.
72
- * Bug Fixes: Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
113
+
114
+ Changes
115
+
116
+ - Default default commands to :help.
117
+ - Remove references to system for options, folder locations, etc. These were not being used and the nature of this tool is that global options should suffice.
118
+
119
+ Bug Fixes
120
+
121
+ - Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
73
122
 
74
123
  ## ['2.2.0'] - 2022-09-24
75
- * Enhancements:
76
- * Add support for `branch-name create` `-x` argument (see `branch-name help create`) which allows you to position the ticket and ticket description within the formulated branch name.
77
- * The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
78
- * Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
79
- * `branch-name create` will now create the PROJECT_LOCATION if it does not exist.
80
- * Update README.md file.
124
+
125
+ Enhancements
126
+
127
+ - Add support for `branch-name create` `-x` argument (see `branch-name help create`) which allows you to position the ticket and ticket description within the formulated branch name.
128
+ - The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
129
+ - Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
130
+ - `branch-name create` will now create the PROJECT_LOCATION if it does not exist.
131
+ - Update README.md file.
81
132
 
82
133
  ## ['2.1.0'] - 2022-09-22
83
- * Enhancements: Add support for Windows clipboard. Branch names created are copied to the clibboard for macOS and Windows now.
134
+
135
+ Enhancements
136
+
137
+ - Add support for Windows clipboard. Branch names created are copied to the clibboard for macOS and Windows now.
84
138
 
85
139
  ## ['2.0.1-beta] - 2022-09-20
86
- * Bug fixes: ticket description was not joined properly (without token separator).
140
+
141
+ Bug fixes
142
+
143
+ - Ticket description was not joined properly (without token separator).
data/Gemfile CHANGED
@@ -5,13 +5,11 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in branch-name.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
9
- gem 'rspec', '~> 3.0'
8
+ gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
9
+ gem 'rake', '~> 13.0', '>= 13.0.6'
10
+ gem 'reek', '~> 6.1', '>= 6.1.4'
11
+ gem 'rspec', '~> 3.12'
10
12
  gem 'rubocop', '~> 1.56.0'
11
-
12
- gem 'pry-byebug', '~> 3.9'
13
- gem 'reek', '~> 6.1', '>= 6.1.1'
14
- # spec.add_development_dependency 'rubocop', '~> 1.35'
15
- # spec.add_development_dependency 'rubocop-performance', '~> 1.14', '>= 1.14.3'
16
- # spec.add_development_dependency 'rubocop-rspec', '~> 2.12', '>= 2.12.1'
13
+ gem 'rubocop-performance', '~> 1.19'
14
+ gem 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
17
15
  gem 'simplecov', '~> 0.22.0'
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.10.2)
5
- activesupport (~> 7.0, >= 7.0.4)
4
+ branch-name (3.10.4)
5
+ activesupport (~> 7.0.8)
6
6
  colorize (>= 0.8.1, < 1.2.0)
7
7
  os (~> 1.1, >= 1.1.4)
8
8
  thor (~> 1.2, >= 1.2.2)
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (7.0.7)
14
+ activesupport (7.0.8)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
@@ -30,10 +30,10 @@ GEM
30
30
  kwalify (0.7.2)
31
31
  language_server-protocol (3.17.0.3)
32
32
  method_source (1.0.0)
33
- minitest (5.19.0)
33
+ minitest (5.20.0)
34
34
  os (1.1.4)
35
35
  parallel (1.23.0)
36
- parser (3.2.2.3)
36
+ parser (3.2.2.4)
37
37
  ast (~> 2.4.1)
38
38
  racc
39
39
  pry (0.14.2)
@@ -42,14 +42,14 @@ GEM
42
42
  pry-byebug (3.10.1)
43
43
  byebug (~> 11.0)
44
44
  pry (>= 0.13, < 0.15)
45
- racc (1.7.1)
45
+ racc (1.7.2)
46
46
  rainbow (3.1.1)
47
- rake (13.0.6)
47
+ rake (13.1.0)
48
48
  reek (6.1.4)
49
49
  kwalify (~> 0.7.0)
50
50
  parser (~> 3.2.0)
51
51
  rainbow (>= 2.0, < 4.0)
52
- regexp_parser (2.8.1)
52
+ regexp_parser (2.8.2)
53
53
  rexml (3.2.6)
54
54
  rspec (3.12.0)
55
55
  rspec-core (~> 3.12.0)
@@ -64,7 +64,7 @@ GEM
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.12.0)
66
66
  rspec-support (3.12.1)
67
- rubocop (1.56.0)
67
+ rubocop (1.56.4)
68
68
  base64 (~> 0.1.1)
69
69
  json (~> 2.3)
70
70
  language_server-protocol (>= 3.17.0)
@@ -76,8 +76,19 @@ GEM
76
76
  rubocop-ast (>= 1.28.1, < 2.0)
77
77
  ruby-progressbar (~> 1.7)
78
78
  unicode-display_width (>= 2.4.0, < 3.0)
79
- rubocop-ast (1.29.0)
79
+ rubocop-ast (1.30.0)
80
80
  parser (>= 3.2.1.0)
81
+ rubocop-capybara (2.19.0)
82
+ rubocop (~> 1.41)
83
+ rubocop-factory_bot (2.24.0)
84
+ rubocop (~> 1.33)
85
+ rubocop-performance (1.19.1)
86
+ rubocop (>= 1.7.0, < 2.0)
87
+ rubocop-ast (>= 0.4.0)
88
+ rubocop-rspec (2.25.0)
89
+ rubocop (~> 1.40)
90
+ rubocop-capybara (~> 2.17)
91
+ rubocop-factory_bot (~> 2.22)
81
92
  ruby-progressbar (1.13.0)
82
93
  simplecov (0.22.0)
83
94
  docile (~> 1.1)
@@ -85,23 +96,26 @@ GEM
85
96
  simplecov_json_formatter (~> 0.1)
86
97
  simplecov-html (0.12.3)
87
98
  simplecov_json_formatter (0.1.4)
88
- thor (1.2.2)
89
- thor_nested_subcommand (1.0.1)
99
+ thor (1.3.0)
100
+ thor_nested_subcommand (1.0.2)
90
101
  tzinfo (2.0.6)
91
102
  concurrent-ruby (~> 1.0)
92
- unicode-display_width (2.4.2)
103
+ unicode-display_width (2.5.0)
93
104
 
94
105
  PLATFORMS
95
106
  x86_64-darwin-19
107
+ x86_64-darwin-21
96
108
  x86_64-linux
97
109
 
98
110
  DEPENDENCIES
99
111
  branch-name!
100
- pry-byebug (~> 3.9)
101
- rake (~> 13.0)
102
- reek (~> 6.1, >= 6.1.1)
103
- rspec (~> 3.0)
112
+ pry-byebug (~> 3.10, >= 3.10.1)
113
+ rake (~> 13.0, >= 13.0.6)
114
+ reek (~> 6.1, >= 6.1.4)
115
+ rspec (~> 3.12)
104
116
  rubocop (~> 1.56.0)
117
+ rubocop-performance (~> 1.19)
118
+ rubocop-rspec (~> 2.23, >= 2.23.2)
105
119
  simplecov (~> 0.22.0)
106
120
 
107
121
  BUNDLED WITH
data/bin/console CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'pry-byebug'
4
5
  require 'bundler/setup'
5
- require 'branch/name'
6
+ require 'branch/name/cli'
6
7
 
7
8
  # You can add fixtures and/or initialization code here to make experimenting
8
9
  # with your gem easier. You can also use a different console, if you like.
@@ -38,52 +38,51 @@ module Branch
38
38
  description and optional ticket'
39
39
  long_desc <<-LONG_DESC
40
40
  NAME
41
- \x5
41
+
42
42
  `branch-name create` -- will formulate a Git branch name based on the
43
43
  DESCRIPTION and optional TICKET provided.
44
44
 
45
45
  SYNOPSIS
46
- \x5
46
+
47
47
  branch-name create [-i|-l|-f|-d|-s|-p|-x] DESCRIPTION [TICKET]
48
48
 
49
- \x5
50
49
  The following options are available:
51
50
 
52
- \x5 NOTE: Default option values will be overidden if .branch-name config files
51
+ NOTE: Default option values will be overidden if .branch-name config files
53
52
  are present. Run `branch-name config info` to determine what config files
54
53
  are present.
55
54
 
56
- \x5 -d: Forces the branch name to lower case.
55
+ -d: Forces the branch name to lower case.
57
56
  The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['downcase']}.
58
57
 
59
- \x5 -f: Used with the -p option. If -f is specified, project files
58
+ -f: Used with the -p option. If -f is specified, project files
60
59
  will be created in the PROJECT_LOCATION specified by the -l option.
61
60
  The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project_files']}.
62
61
 
63
- \x5 -i: Interactive. Used with the -p option. If -i is specified, you will
62
+ -i: Interactive. Used only with the -p option. If -i is specified, you will
64
63
  be prompted when creating project folders. If -i is not specified, you will
65
64
  NOT be prompted when creating project folders.
66
65
 
67
- \x5\x5 -l PROJECT_LOCATION: Indicates where the project should be created.
66
+ -l PROJECT_LOCATION: Indicates where the project should be created.
68
67
  A "project" is a folder that is created in the PROJECT_LOCATION specified,
69
68
  whose name is equivalent to the branch name that is formulated.
70
69
  The default is: "#{Locatable.project_folder(options: options)}".
71
70
 
72
- \x5\x5 -p: Indicates that a project should be created.
71
+ -p: Indicates that a project should be created.
73
72
  The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project']}.
74
73
 
75
- \x5\x5 -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
74
+ -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
76
75
  The default SEPARATOR is: '#{DEFAULT_BRANCH_NAME_OPTIONS['create']['separator']}'.
77
76
 
78
- \x5 -x FORMAT_STRING: This is a string that determines the format of the branch name
77
+ -x FORMAT_STRING: This is a string that determines the format of the branch name
79
78
  that is formulated. The following is a list of required placeholders you must put
80
79
  in your format string to format the branch name: [%t, %d].
81
- \x5Where %t will be replaced by the ticket.
82
- \x5Where %d will be replaced by the ticket description.
83
- \x5The following is a list of optional placeholders you may put
80
+ Where %t will be replaced by the ticket.
81
+ Where %d will be replaced by the ticket description.
82
+ The following is a list of optional placeholders you may put
84
83
  in your format string to format the branch name: [%u].
85
- \x5Where %u will be replaced with your username (`Etc.getlogin`, https://rubygems.org/gems/etc).
86
- \x5The default format string is: "#{DEFAULT_BRANCH_NAME_OPTIONS['create']['format_string']}".
84
+ Where %u will be replaced with your username (`Etc.getlogin`, https://rubygems.org/gems/etc).
85
+ The default format string is: "#{DEFAULT_BRANCH_NAME_OPTIONS['create']['format_string']}".
87
86
  LONG_DESC
88
87
  method_option :downcase, type: :boolean, aliases: '-d'
89
88
  method_option :separator, type: :string, aliases: '-s'
@@ -91,28 +90,25 @@ module Branch
91
90
  method_option :project, type: :boolean, aliases: '-p'
92
91
  method_option :project_location, type: :string, aliases: '-l'
93
92
  method_option :project_files, type: :array, aliases: '-f'
94
- method_option :interactive, type: :boolean, aliases: '-i'
93
+ method_option :interactive, type: :boolean, optional: true, aliases: '-i'
95
94
 
96
95
  def create(ticket_description, ticket = nil)
97
- if ticket_description.blank?
98
- say_error 'description is required', ERROR
99
- exit 1
100
- end
96
+ validate_ticket_description! ticket_description
97
+ original_options, altered_options = init_options_for! command: :create
98
+ self.options = altered_options
101
99
 
102
- init_options_for! command: :create
103
-
104
- branch_name = normalize_branch_name(ticket_description, ticket) do |error|
105
- say_error error.message
106
- exit 1
107
- end
100
+ branch_name = validate_and_normalize_branch_name(ticket_description, ticket)
108
101
  say "Branch name: \"#{branch_name}\"", :cyan
109
102
  say "Branch name \"#{branch_name}\" has been copied to the clipboard!", SUCCESS if copy_to_clipboard branch_name
103
+ if original_options[:interactive] && !options[:project]
104
+ say 'Ignored: -i is only used with projects (-p).',
105
+ WARNING
106
+ end
107
+ interactive_default = options['interactive']
108
+ options[:interactive] = interactive_default if original_options[:interactive].nil?
110
109
 
111
110
  if options[:project]
112
- project_folder_name = project_folder_name_from(branch_name) do |error|
113
- say_error error.message
114
- exit 1
115
- end
111
+ project_folder_name = validate_and_create_project_folder_name_from! branch_name
116
112
  if options[:interactive]
117
113
  project_folder = project_folder_for branch_name
118
114
  unless yes? "Create project for branch \"#{branch_name}\" " \
@@ -137,15 +133,42 @@ module Branch
137
133
 
138
134
  private
139
135
 
136
+ def validate_ticket_description!(ticket_description)
137
+ return unless ticket_description.blank?
138
+
139
+ say_error 'description is required', ERROR
140
+ exit 1
141
+ end
142
+
143
+ def validate_and_normalize_branch_name(ticket_description, ticket)
144
+ normalize_branch_name(ticket_description, ticket) do |error|
145
+ say_error error.message
146
+ exit 1
147
+ end
148
+ end
149
+
150
+ def validate_and_create_project_folder_name_from!(branch_name)
151
+ project_folder_name_from(branch_name) do |error|
152
+ say_error error.message
153
+ exit 1
154
+ end
155
+ end
156
+
140
157
  def init_options_for!(command:)
158
+ options_array = []
159
+ options_array << options.dup
160
+
141
161
  say "Options before config file merge: #{options}" if options[:debug]
142
162
 
143
- load_options = load_options(defaults: DEFAULT_BRANCH_NAME_OPTIONS)[command.to_s] || {}
144
- say "No options loaded from config file(s): #{load_options}" if options[:debug] && load_options.blank?
145
- say "Options loaded from config file(s): #{load_options}" if options[:debug]
163
+ (load_options(defaults: DEFAULT_BRANCH_NAME_OPTIONS)[command.to_s] || {}).tap do |load_options|
164
+ say "No options loaded from config file(s): #{load_options}" if options[:debug] && load_options.blank?
165
+ say "Options loaded from config file(s): #{load_options}" if options[:debug]
166
+
167
+ options_array << Thor::CoreExt::HashWithIndifferentAccess.new(load_options.merge(options))
168
+ say "Options after config file merge: #{options_array.last}" if options_array.last[:debug]
169
+ end
146
170
 
147
- self.options = Thor::CoreExt::HashWithIndifferentAccess.new(load_options.merge(options))
148
- say "Options after config file merge: #{options}" if options[:debug]
171
+ options_array
149
172
  end
150
173
  end
151
174
  end
@@ -28,14 +28,12 @@ module Branch
28
28
  }.freeze
29
29
  # rubocop:enable Style/StringHashKeys
30
30
 
31
- module_function
32
-
33
31
  def global_config_file
34
- File.join(global_folder, CONFIG_FILENAME)
32
+ File.join(Locatable.global_folder, CONFIG_FILENAME)
35
33
  end
36
34
 
37
35
  def local_config_file
38
- File.join(local_folder, CONFIG_FILENAME)
36
+ File.join(Locatable.local_folder, CONFIG_FILENAME)
39
37
  end
40
38
 
41
39
  def global_config_file?
@@ -47,12 +45,16 @@ module Branch
47
45
  end
48
46
 
49
47
  def create_global_config_file!
50
- create_config_file global_config_file
48
+ create_options = DEFAULT_BRANCH_NAME_OPTIONS
49
+ yield create_options if block_given?
50
+ create_config_file global_config_file, create_options: create_options
51
51
  print_global_config_file
52
52
  end
53
53
 
54
54
  def create_local_config_file!
55
- create_config_file local_config_file
55
+ create_options = DEFAULT_BRANCH_NAME_OPTIONS
56
+ yield create_options if block_given?
57
+ create_config_file local_config_file, create_options: create_options
56
58
  print_local_config_file
57
59
  end
58
60
 
@@ -84,9 +86,7 @@ module Branch
84
86
  end
85
87
  end
86
88
 
87
- private
88
-
89
- def create_config_file(config_file)
89
+ def create_config_file(config_file, create_options:)
90
90
  folder = File.dirname(config_file)
91
91
  unless Dir.exist?(folder)
92
92
  say "Destination folder for configuration file (#{folder}) does not exist", ERROR
@@ -98,12 +98,14 @@ module Branch
98
98
  return false
99
99
  end
100
100
 
101
- File.write(config_file, DEFAULT_BRANCH_NAME_OPTIONS.to_yaml)
101
+ File.write(config_file, create_options.to_yaml)
102
102
  say "Configuration file (#{config_file}) created.", SUCCESS
103
103
 
104
104
  true
105
105
  end
106
106
 
107
+ private
108
+
107
109
  def delete_config_file(config_file)
108
110
  unless File.exist?(config_file)
109
111
  say "Configuration file (#{config_file}) does not exist", WARNING
@@ -19,6 +19,11 @@ module Branch
19
19
  Dir.pwd
20
20
  end
21
21
 
22
+ # Is the current folder we're in the same as the global folder?
23
+ def global_folder?
24
+ global_folder == local_folder
25
+ end
26
+
22
27
  def project_folder(options: {})
23
28
  return home_folder if options.blank?
24
29
 
@@ -18,16 +18,23 @@ module Branch
18
18
  desc 'info', 'Displays information about this gem configuration'
19
19
  long_desc <<-LONG_DESC
20
20
  NAME
21
- \x5
21
+
22
22
  `branch-name config info` -- Displays information about this gem configuration.
23
23
 
24
24
  SYNOPSIS
25
- \x5
25
+
26
26
  branch-name config info
27
27
  LONG_DESC
28
28
  def info
29
29
  print_global_config_file
30
30
  say ''
31
+
32
+ if global_folder?
33
+ say 'NOTE: You are in your global folder. ' \
34
+ 'Local and global configurations are the same.'.colorize(:yellow)
35
+ return
36
+ end
37
+
31
38
  print_local_config_file
32
39
  end
33
40
 
@@ -24,11 +24,11 @@ module Branch
24
24
  desc 'all', 'Deletes all config files (local and global) for this gem'
25
25
  long_desc <<-LONG_DESC
26
26
  NAME
27
- \x5
27
+
28
28
  `branch-name config delete all` -- will remove the all .branch-name config files.
29
29
 
30
30
  SYNOPSIS
31
- \x5
31
+
32
32
  branch-name config delete all
33
33
  LONG_DESC
34
34
  def all
@@ -39,11 +39,11 @@ module Branch
39
39
  desc 'global', 'Deletes the global config file for this gem'
40
40
  long_desc <<-LONG_DESC
41
41
  NAME
42
- \x5
42
+
43
43
  `branch-name config delete global` -- will remove the global .branch-name config file.
44
44
 
45
45
  SYNOPSIS
46
- \x5
46
+
47
47
  branch-name config delete global
48
48
  LONG_DESC
49
49
  def global
@@ -53,11 +53,11 @@ module Branch
53
53
  desc 'local', 'Deletes the local config file for this gem'
54
54
  long_desc <<-LONG_DESC
55
55
  NAME
56
- \x5
56
+
57
57
  `branch-name config delete local` -- will remove the local .branch-name config file.
58
58
 
59
59
  SYNOPSIS
60
- \x5
60
+
61
61
  branch-name config delete local
62
62
  LONG_DESC
63
63
  def local
@@ -24,12 +24,12 @@ module Branch
24
24
  desc 'global', 'Creates and initializes a .branch-name file in the global folder'
25
25
  long_desc <<-LONG_DESC
26
26
  NAME
27
- \x5
27
+
28
28
  `branch-name config init global` -- will create and initialize a .branch-name file
29
29
  in the "#{Locatable.global_folder}" folder.
30
30
 
31
31
  SYNOPSIS
32
- \x5
32
+
33
33
  branch-name config init global
34
34
  LONG_DESC
35
35
  def global
@@ -39,12 +39,12 @@ module Branch
39
39
  desc 'local', 'Creates and initializes a .branch-name file in the local folder'
40
40
  long_desc <<-LONG_DESC
41
41
  NAME
42
- \x5
42
+
43
43
  `branch-name config init local` -- will create and initialize a .branch-name file
44
44
  in the "#{Locatable.local_folder}" folder.
45
45
 
46
46
  SYNOPSIS
47
- \x5
47
+
48
48
  branch-name config init local
49
49
  LONG_DESC
50
50
  def local
@@ -3,6 +3,6 @@
3
3
  module Branch
4
4
  module Name
5
5
  # branch-name version
6
- VERSION = '3.10.2'
6
+ VERSION = '3.10.4'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branch-name
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.2
4
+ version: 3.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-18 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 7.0.4
19
+ version: 7.0.8
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '7.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 7.0.4
26
+ version: 7.0.8
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: colorize
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
171
  - !ruby/object:Gem::Version
178
172
  version: '0'
179
173
  requirements: []
180
- rubygems_version: 3.3.22
174
+ rubygems_version: 3.2.15
181
175
  signing_key:
182
176
  specification_version: 4
183
177
  summary: Generates a branch name based on a JIRA ticket/ticket number.