branch-name 3.10.1 → 3.10.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c60a895aec9cd58b16877a4d8997c3165a17c99bd353c05f9034448d2bf8ae92
4
- data.tar.gz: d268c31604c46ec6ffe6c1312484acf74e5f933b045c434227b76d12155a23b5
3
+ metadata.gz: 5ab9f37a984715c52a3c0952d554f14c4c031f88b91c5dfb6fbfb7147f576633
4
+ data.tar.gz: '09619b8e08559e13b2e9e8c236c2d849e620019fd44bc9868d2d1e564813d9ea'
5
5
  SHA512:
6
- metadata.gz: d3e942702075ebb43a15411993b746aa8656d1e01f87595f230ac3e2b0b30240967edf24494ca194637193b88551ee5142a89d7fd7bcb30d05bbe82f23fe67c5
7
- data.tar.gz: 196a9e4834d47c8094b9fcafd6dcdcaa14631137ad1a7b304c1f090dda57f7180cc3e00450946581ff982b89740d7e5836a18f26a14bde496e740b9058dd8a88
6
+ metadata.gz: 25805fbe99145fd386f48c36979fbf4ec1cb3102ea927a819d7fb8cbaa33ccda80519a70babc0f36317b4bc733d70dce314733e70ef88c5d173e375c40186ec3
7
+ data.tar.gz: 52107197383539295ff02f687db9adbc133be2b31332b3822b263a5568d36afadea8ff94d51c3628745aaf47cb8c1fd53a32127e18092f058e1627cb4933aee1
data/.rubocop.yml CHANGED
@@ -11,6 +11,7 @@ AllCops:
11
11
  - 'init/*'
12
12
  - 'Rakefile'
13
13
  - 'vendor/**/*'
14
+ - 'spec/**/*'
14
15
  - 'scratch*.rb'
15
16
 
16
17
  # Align the elements of a hash literal if they span more than one line.
data/CHANGELOG.md CHANGED
@@ -1,82 +1,137 @@
1
+ ## ['3.10.3'] - 2023-08-18
2
+
3
+ Changes
4
+
5
+ - Update gems.
6
+ - Various code refactors.
7
+ - Add some more test coverage.
8
+
9
+ ## ['3.10.2'] - 2023-08-17
10
+
11
+ Changes
12
+
13
+ - Update gems.
14
+
1
15
  ## ['3.10.1'] - 2023-03-22
2
- * Changes
3
- * Update gems. Remedy an activesupport dependabot alert.
16
+
17
+ Changes
18
+
19
+ - Update gems. Remedy an activesupport dependabot alert.
4
20
 
5
21
  ## ['3.10.0'] - 2023-02-16
6
- * Changes
7
- * Update gems.
22
+
23
+ Changes
24
+
25
+ - Update gems.
8
26
 
9
27
  ## ['3.9.0'] - 2022-11-04
10
- * Changes
11
- * Update gems.
28
+
29
+ Changes
30
+
31
+ - Update gems.
12
32
 
13
33
  ## ['3.8.0'] - 2022-11-04
14
- * Changes
15
- * Limit gem version to ~> 3.0 to avoid breaking changes.
34
+
35
+ Changes
36
+
37
+ - Limit gem version to ~> 3.0 to avoid breaking changes.
16
38
 
17
39
  ## ['3.7.0'] - 2022-10-06
18
- * Changes
19
- * Use thor_nested_subcommand to fix Thor nested subcommand help bug.
20
- * Add missing global config option for create: :interactive.
40
+
41
+ Changes
42
+
43
+ - Use thor_nested_subcommand to fix Thor nested subcommand help bug.
44
+ - Add missing global config option for create: :interactive.
21
45
 
22
46
  ## ['3.6.0'] - 2022-10-06
23
- * Changes
24
- * 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.
25
- * Update the README.md file accordign to the aforementioned.
47
+
48
+ Changes
49
+
50
+ - 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.
51
+ - Update the README.md file accordign to the aforementioned.
26
52
 
27
53
  ## ['3.5.1'] - 2022-10-05
28
- * Bug Fixes
29
- * Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
30
- * 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.
31
- * Changes
32
- * Add test coverage for the above scenarios.
33
- * Use File.join to join paths and files safely where appropriate.
34
- * Update .gemspec gem description with more detail.
54
+
55
+ Changes
56
+
57
+ - Add test coverage for the above scenarios.
58
+ - Use File.join to join paths and files safely where appropriate.
59
+ - Update .gemspec gem description with more detail.
60
+
61
+ Bug Fixes
62
+
63
+ - Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
64
+ - 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
65
 
36
66
  ## ['3.5.0'] - 2022-10-04
37
- * Changes
38
- * Fix broken link to CHANGELOG.md in .gemspec file.
67
+
68
+ Changes
69
+
70
+ - Fix broken link to CHANGELOG.md in .gemspec file.
39
71
 
40
72
  ## ['3.4.0'] - 2022-10-04
41
- * Changes
42
- * `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.
43
- * Various changes in information printed to stdout when (for example) creating projects.
73
+
74
+ Changes
75
+
76
+ - `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.
77
+ - Various changes in information printed to stdout when (for example) creating projects.
44
78
 
45
79
  ## ['3.3.0'] - 2022-09-27
46
- * Enhancements:
47
- * `branch-name config info` now displays the contents of both the Global and the local config files.
80
+
81
+ Enhancements
82
+
83
+ - `branch-name config info` now displays the contents of both the Global and the local config files.
48
84
 
49
85
  ## ['3.2.2'] - 2022-09-27
50
- * Changes:
51
- * Refactor code that patches Thor incorrect display of nested commands (subcommangs).
86
+
87
+ Changes
88
+
89
+ - Refactor code that patches Thor incorrect display of nested commands (subcommangs).
52
90
 
53
91
  ## ['3.2.1'] - 2022-09-27
54
- * Changes:
55
- * Fix rubocop violations.
56
- * Miscellaneous mixin refactors.
57
- * Bug Fixes: Fix bug that displayed subcommand help incorrectly.
92
+
93
+ Changes
94
+
95
+ - Fix rubocop violations.
96
+ - Miscellaneous mixin refactors.
97
+ - Bug Fixes: Fix bug that displayed subcommand help incorrectly.
58
98
 
59
99
  ## ['3.1.0'] - 2022-09-26
60
- * Enhancements:
61
- * Branch names may now be created using a forward-slash (/). See the README.md file for more information.
62
- * 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.
100
+
101
+ Enhancements
102
+
103
+ - Branch names may now be created using a forward-slash (/). See the README.md file for more information.
104
+ - 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.
63
105
 
64
106
  ## ['3.0.0'] - 2022-09-26
65
- * Changes:
66
- * Default default commands to :help.
67
- * 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.
68
- * Bug Fixes: Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
107
+
108
+ Changes
109
+
110
+ - Default default commands to :help.
111
+ - 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.
112
+
113
+ Bug Fixes
114
+
115
+ - Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
69
116
 
70
117
  ## ['2.2.0'] - 2022-09-24
71
- * Enhancements:
72
- * 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.
73
- * The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
74
- * Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
75
- * `branch-name create` will now create the PROJECT_LOCATION if it does not exist.
76
- * Update README.md file.
118
+
119
+ Enhancements
120
+
121
+ - 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.
122
+ - The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
123
+ - Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
124
+ - `branch-name create` will now create the PROJECT_LOCATION if it does not exist.
125
+ - Update README.md file.
77
126
 
78
127
  ## ['2.1.0'] - 2022-09-22
79
- * Enhancements: Add support for Windows clipboard. Branch names created are copied to the clibboard for macOS and Windows now.
128
+
129
+ Enhancements
130
+
131
+ - Add support for Windows clipboard. Branch names created are copied to the clibboard for macOS and Windows now.
80
132
 
81
133
  ## ['2.0.1-beta] - 2022-09-20
82
- * Bug fixes: ticket description was not joined properly (without token separator).
134
+
135
+ Bug fixes
136
+
137
+ - 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'
10
- gem 'rubocop', '~> 0.81.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'
17
- gem 'simplecov', '~> 0.21.2'
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'
12
+ gem 'rubocop', '~> 1.56.0'
13
+ gem 'rubocop-performance', '~> 1.19'
14
+ gem 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
15
+ gem 'simplecov', '~> 0.22.0'
data/Gemfile.lock CHANGED
@@ -1,96 +1,122 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.10.1)
4
+ branch-name (3.10.3)
5
5
  activesupport (~> 7.0, >= 7.0.4)
6
- colorize (~> 0.8.1)
6
+ colorize (>= 0.8.1, < 1.2.0)
7
7
  os (~> 1.1, >= 1.1.4)
8
- thor (~> 1.2, >= 1.2.1)
9
- thor_nested_subcommand (~> 1.0)
8
+ thor (~> 1.2, >= 1.2.2)
9
+ thor_nested_subcommand (~> 1.0, >= 1.0.1)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (7.0.4.3)
14
+ activesupport (7.0.7.2)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
18
18
  tzinfo (~> 2.0)
19
19
  ast (2.4.2)
20
+ base64 (0.1.1)
20
21
  byebug (11.1.3)
21
22
  coderay (1.1.3)
22
- colorize (0.8.1)
23
+ colorize (1.1.0)
23
24
  concurrent-ruby (1.2.2)
24
25
  diff-lcs (1.5.0)
25
26
  docile (1.4.0)
26
- i18n (1.12.0)
27
+ i18n (1.14.1)
27
28
  concurrent-ruby (~> 1.0)
28
- jaro_winkler (1.5.4)
29
+ json (2.6.3)
29
30
  kwalify (0.7.2)
31
+ language_server-protocol (3.17.0.3)
30
32
  method_source (1.0.0)
31
- minitest (5.18.0)
33
+ minitest (5.19.0)
32
34
  os (1.1.4)
33
- parallel (1.22.1)
34
- parser (3.2.1.1)
35
+ parallel (1.23.0)
36
+ parser (3.2.2.3)
35
37
  ast (~> 2.4.1)
38
+ racc
36
39
  pry (0.14.2)
37
40
  coderay (~> 1.1)
38
41
  method_source (~> 1.0)
39
42
  pry-byebug (3.10.1)
40
43
  byebug (~> 11.0)
41
44
  pry (>= 0.13, < 0.15)
45
+ racc (1.7.1)
42
46
  rainbow (3.1.1)
43
47
  rake (13.0.6)
44
48
  reek (6.1.4)
45
49
  kwalify (~> 0.7.0)
46
50
  parser (~> 3.2.0)
47
51
  rainbow (>= 2.0, < 4.0)
48
- rexml (3.2.5)
52
+ regexp_parser (2.8.1)
53
+ rexml (3.2.6)
49
54
  rspec (3.12.0)
50
55
  rspec-core (~> 3.12.0)
51
56
  rspec-expectations (~> 3.12.0)
52
57
  rspec-mocks (~> 3.12.0)
53
- rspec-core (3.12.1)
58
+ rspec-core (3.12.2)
54
59
  rspec-support (~> 3.12.0)
55
- rspec-expectations (3.12.2)
60
+ rspec-expectations (3.12.3)
56
61
  diff-lcs (>= 1.2.0, < 2.0)
57
62
  rspec-support (~> 3.12.0)
58
- rspec-mocks (3.12.4)
63
+ rspec-mocks (3.12.6)
59
64
  diff-lcs (>= 1.2.0, < 2.0)
60
65
  rspec-support (~> 3.12.0)
61
- rspec-support (3.12.0)
62
- rubocop (0.81.0)
63
- jaro_winkler (~> 1.5.1)
66
+ rspec-support (3.12.1)
67
+ rubocop (1.56.1)
68
+ base64 (~> 0.1.1)
69
+ json (~> 2.3)
70
+ language_server-protocol (>= 3.17.0)
64
71
  parallel (~> 1.10)
65
- parser (>= 2.7.0.1)
72
+ parser (>= 3.2.2.3)
66
73
  rainbow (>= 2.2.2, < 4.0)
67
- rexml
74
+ regexp_parser (>= 1.8, < 3.0)
75
+ rexml (>= 3.2.5, < 4.0)
76
+ rubocop-ast (>= 1.28.1, < 2.0)
68
77
  ruby-progressbar (~> 1.7)
69
- unicode-display_width (>= 1.4.0, < 2.0)
78
+ unicode-display_width (>= 2.4.0, < 3.0)
79
+ rubocop-ast (1.29.0)
80
+ parser (>= 3.2.1.0)
81
+ rubocop-capybara (2.18.0)
82
+ rubocop (~> 1.41)
83
+ rubocop-factory_bot (2.23.1)
84
+ rubocop (~> 1.33)
85
+ rubocop-performance (1.19.0)
86
+ rubocop (>= 1.7.0, < 2.0)
87
+ rubocop-ast (>= 0.4.0)
88
+ rubocop-rspec (2.23.2)
89
+ rubocop (~> 1.33)
90
+ rubocop-capybara (~> 2.17)
91
+ rubocop-factory_bot (~> 2.22)
70
92
  ruby-progressbar (1.13.0)
71
- simplecov (0.21.2)
93
+ simplecov (0.22.0)
72
94
  docile (~> 1.1)
73
95
  simplecov-html (~> 0.11)
74
96
  simplecov_json_formatter (~> 0.1)
75
97
  simplecov-html (0.12.3)
76
98
  simplecov_json_formatter (0.1.4)
77
- thor (1.2.1)
78
- thor_nested_subcommand (1.0.0)
99
+ thor (1.2.2)
100
+ thor_nested_subcommand (1.0.1)
79
101
  tzinfo (2.0.6)
80
102
  concurrent-ruby (~> 1.0)
81
- unicode-display_width (1.8.0)
103
+ unicode-display_width (2.4.2)
82
104
 
83
105
  PLATFORMS
84
106
  x86_64-darwin-19
107
+ x86_64-darwin-21
108
+ x86_64-linux
85
109
 
86
110
  DEPENDENCIES
87
111
  branch-name!
88
- pry-byebug (~> 3.9)
89
- rake (~> 13.0)
90
- reek (~> 6.1, >= 6.1.1)
91
- rspec (~> 3.0)
92
- rubocop (~> 0.81.0)
93
- simplecov (~> 0.21.2)
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)
116
+ rubocop (~> 1.56.0)
117
+ rubocop-performance (~> 1.19)
118
+ rubocop-rspec (~> 2.23, >= 2.23.2)
119
+ simplecov (~> 0.22.0)
94
120
 
95
121
  BUNDLED WITH
96
122
  2.3.22
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.1'
6
+ VERSION = '3.10.3'
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.1
4
+ version: 3.10.3
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-03-22 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -34,16 +34,22 @@ dependencies:
34
34
  name: colorize
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 0.8.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 1.2.0
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - "~>"
47
+ - - ">="
45
48
  - !ruby/object:Gem::Version
46
49
  version: 0.8.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 1.2.0
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: os
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +79,7 @@ dependencies:
73
79
  version: '1.2'
74
80
  - - ">="
75
81
  - !ruby/object:Gem::Version
76
- version: 1.2.1
82
+ version: 1.2.2
77
83
  type: :runtime
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,7 +89,7 @@ dependencies:
83
89
  version: '1.2'
84
90
  - - ">="
85
91
  - !ruby/object:Gem::Version
86
- version: 1.2.1
92
+ version: 1.2.2
87
93
  - !ruby/object:Gem::Dependency
88
94
  name: thor_nested_subcommand
89
95
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +97,9 @@ dependencies:
91
97
  - - "~>"
92
98
  - !ruby/object:Gem::Version
93
99
  version: '1.0'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.0.1
94
103
  type: :runtime
95
104
  prerelease: false
96
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -98,6 +107,9 @@ dependencies:
98
107
  - - "~>"
99
108
  - !ruby/object:Gem::Version
100
109
  version: '1.0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.0.1
101
113
  description: |2
102
114
  branch-name is a gem that provides a command-line interface that allows you to accomplish several tasks, tasks I personally find myself having to carry out every time I work on a feature branch. I created this gem for myself; however, you are free to use it yourself, if any of these tasks fits into your personal routine:
103
115
 
@@ -165,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
177
  - !ruby/object:Gem::Version
166
178
  version: '0'
167
179
  requirements: []
168
- rubygems_version: 3.3.22
180
+ rubygems_version: 3.2.15
169
181
  signing_key:
170
182
  specification_version: 4
171
183
  summary: Generates a branch name based on a JIRA ticket/ticket number.