branch-name 3.5.1 → 3.7.0

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: 6eaa01fba6e3bd5d848e9ddc6e349f9e9d1f4fd0261e181cc82e78cb68c3e286
4
- data.tar.gz: 2abb17e38a16bc28fc8690ea1aa805fb04171982bba7e047250e88cad137088a
3
+ metadata.gz: 4b75833e2db0f7f5eeb6c662e83a46abac3740b6de855f41b120b4e48c5882a9
4
+ data.tar.gz: e291f3c4b834c1fa2e6c11b7225b1f2aa2c1f827306ae8cb9b7cbeda3225e460
5
5
  SHA512:
6
- metadata.gz: 9b192d2562ca49009723cc1c1f7f6493ad7df71f35ec07ad47021c5ffa1f27a22fdcd2826ff39539437a0be87d7f6a4b33f1afd766a09d04f614a4dff8b3ec2f
7
- data.tar.gz: 744f98d3f15956db6265aa560aa59ea3036060fd006141a08755b2c6b0b9746a54cc302013f4d3bc56a4c7dc161135c8cef41505c7e8b37f42426cfa6c855ad4
6
+ metadata.gz: 52ce1452b89586e01d82d1ad78c337cbe83a15ca48ddab80dee52f62a0a9330433bbd6845bc716234e1d656700389222fbcdab80f1337be07e7f282169aeb2db
7
+ data.tar.gz: f5604c5537195e20c17478382c161d4ca7bf29998fe6818d1e1a9f68071491d270e5e67a79fdf7f428907b0e649f1b9397dec74c0dcdfef7f76791fb6ca70b45
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## ['3.7.0'] - 2022-10-06
2
+ * Changes
3
+ * Use thor_nested_subcommand to fix Thor nested subcommand help bug.
4
+ * Add missing global config option for create: :interactive.
5
+
6
+ ## ['3.6.0'] - 2022-10-06
7
+ * Changes
8
+ * 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.
9
+ * Update the README.md file accordign to the aforementioned.
10
+
1
11
  ## ['3.5.1'] - 2022-10-05
2
12
  * Bug Fixes
3
13
  * Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.5.1)
4
+ branch-name (3.7.0)
5
5
  activesupport (~> 7.0, >= 7.0.4)
6
6
  colorize (~> 0.8.1)
7
7
  os (~> 1.1, >= 1.1.4)
8
8
  thor (~> 1.2, >= 1.2.1)
9
+ thor_nested_subcommand (~> 1.0)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -74,6 +75,7 @@ GEM
74
75
  simplecov-html (0.12.3)
75
76
  simplecov_json_formatter (0.1.4)
76
77
  thor (1.2.1)
78
+ thor_nested_subcommand (1.0.0)
77
79
  tzinfo (2.0.5)
78
80
  concurrent-ruby (~> 1.0)
79
81
  unicode-display_width (1.8.0)
data/README.md CHANGED
@@ -70,13 +70,14 @@ create:
70
70
  - readme.txt
71
71
  - scratch.rb
72
72
  - snippets.rb
73
+ interactive: true
73
74
  ```
74
75
 
75
76
  NOTE: You can manually change any of the options you wish. It is recommended that you change the default `create: project_location` to meet your needs, depending on your *os*. For example, on *macOS* you might want to change this to `"/Users/<username>/Documents"`, `"/Users/<username>/Documents/features"`, or something similar.
76
77
 
77
78
  The `create: project_location` option string also accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directives.
78
79
 
79
- The `create: format_string` option string can be used to position the *ticket* (`%t`) and *ticket description* (`%d`) within the branch name formulated. You can also include any other information you wish in the format string, for example: "`<username> %t %d`". However, non-word characters will be stripped (see `Branch::Name::Normalizable::NON_WORD_CHARS_REGEX` which equates to `/[\W_]/`)
80
+ The `create: format_string` option string can be used to position the *ticket* (`%t`) and *ticket description* (`%d`) within the branch name formulated. You can also include any other information you wish in the format string, for example: "`<username> %t %d`". However, particular characters will be stripped to formulate the branch name (see `Branch::Name::Normalizable::BRANCH_NAME_REGEX` which equates to `%r{[^/\w\x20]|_}`).
80
81
 
81
82
  Any or all of these options can also be overwritten on the command-line. For more information:
82
83
  `$ branch-name config help init`
@@ -100,14 +101,17 @@ create:
100
101
  - readme.txt
101
102
  - scratch.rb
102
103
  - snippets.rb
104
+ interactive: true
103
105
  ```
104
106
 
105
- This example formulates feature a branch named *lg-12345-pay-down-tech-debt-on-user-model* by converting the ticket and ticket description to lowercase (`-d`) and delimiting the feature branch name tokens with a "-" character (`-s -`). The `-p` option instructs `branch-name create` to create the project folder */Users/<username>/feature-branches/2022/lg-12345-pay-down-tech-debt-on-user-model*. The aforementioned project folder will also contain the following files: readme.txt, scratch.rb and snippets.rb. In addition to this, `branch-name create` will also copy the feature brach name to the clipboard for you (macOS and Windows currently supported). This is convenient when you need to create a feature branch in github, or from the command-line.
107
+ This example formulates feature a branch named *lg-12345-pay-down-tech-debt-on-user-model* by converting the ticket and ticket description to lowercase (`-d`) and delimiting the feature branch name tokens with a "-" character (`-s -`). The `-p` option instructs `branch-name create` to create the project folder */Users/<username>/feature-branches/2022/lg-12345-pay-down-tech-debt-on-user-model*, and finally, the `-i false` option instructs `branch-name` to *not* prompt the user when creating projects. The aforementioned project folder will also contain the following files: readme.txt, scratch.rb and snippets.rb. In addition to this, `branch-name create` will also copy the feature brach name to the clipboard for you (macOS and Windows currently supported). This is convenient when you need to create a feature branch in github, or from the command-line.
106
108
 
107
109
  ```shell
108
- $ branch-name create -p -d -s - "Pay down tech debt on User model" LG-12345
110
+ $ branch-name create -i false -p -d -s - "Pay down tech debt on User model" LG-12345
109
111
  ```
110
112
 
113
+ NOTE: When creating projects, `branch-name` will prompt you if the `interactive` option is true (`-i`).
114
+
111
115
  This example simply formulates feature a branch named *Add_create_and_destroy_session_controller_actions* and copies it to the clipboard.
112
116
 
113
117
  ```shell
@@ -133,7 +137,7 @@ $ branch-name create "<username>/UX-54321 Remove debug code"
133
137
  ...
134
138
  ```
135
139
 
136
- NOTE: Project folders created (`--project/-p`) will replace any forward-slash with the `create: :separator` option value.
140
+ NOTE: Project folders that are formulated (`branch-name create [-p|--project] ...`), will have any tokens comprising the project folder name delimited according to the following rules: 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 delimiter; otherwise, `Branch::Name::Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR` will be used.
137
141
 
138
142
  ## Development
139
143
 
data/branch-name.gemspec CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_dependency 'colorize', '~> 0.8.1'
43
43
  spec.add_dependency 'os', '~> 1.1', '>= 1.1.4'
44
44
  spec.add_dependency 'thor', '~> 1.2', '>= 1.2.1'
45
+ spec.add_dependency 'thor_nested_subcommand', '~> 1.0'
45
46
 
46
47
  # Remove this for now.
47
48
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -44,42 +44,46 @@ module Branch
44
44
 
45
45
  SYNOPSIS
46
46
  \x5
47
- branch-name create [-l|-f|-d|-s|-p|-x] DESCRIPTION [TICKET]
47
+ branch-name create [-i|-l|-f|-d|-s|-p|-x] DESCRIPTION [TICKET]
48
48
 
49
49
  \x5
50
50
  The following options are available:
51
51
 
52
52
  \x5 NOTE: Default option values will be overidden if .branch-name config files
53
- are present. Run `branch-name config info` to determine what config files
54
- are present.
53
+ are present. Run `branch-name config info` to determine what config files
54
+ are present.
55
55
 
56
56
  \x5 -d: Forces the branch name to lower case.
57
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['downcase']}.
58
-
59
- \x5\x5 -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
60
- The default SEPARATOR is: '#{DEFAULT_BRANCH_NAME_OPTIONS['create']['separator']}'.
61
-
62
- \x5\x5 -p: Indicates that a project should be created.
63
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project']}.
57
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['downcase']}.
64
58
 
65
59
  \x5 -f: Used with the -p option. If -f is specified, project files
66
- will be created in the PROJECT_LOCATION specified by the -l option.
67
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project_files']}.
60
+ will be created in the PROJECT_LOCATION specified by the -l option.
61
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project_files']}.
62
+
63
+ \x5 -i: Interactive. Used with the -p option. If -i is specified, you will
64
+ be prompted when creating project folders. If -i is not specified, you will
65
+ NOT be prompted when creating project folders.
68
66
 
69
67
  \x5\x5 -l PROJECT_LOCATION: Indicates where the project should be created.
70
- A "project" is a folder that is created in the PROJECT_LOCATION specified,
71
- whose name is equivalent to the branch name that is formulated.
72
- The default is: "#{Locatable.project_folder(options: options)}".
68
+ A "project" is a folder that is created in the PROJECT_LOCATION specified,
69
+ whose name is equivalent to the branch name that is formulated.
70
+ The default is: "#{Locatable.project_folder(options: options)}".
71
+
72
+ \x5\x5 -p: Indicates that a project should be created.
73
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project']}.
74
+
75
+ \x5\x5 -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
76
+ The default SEPARATOR is: '#{DEFAULT_BRANCH_NAME_OPTIONS['create']['separator']}'.
73
77
 
74
78
  \x5 -x FORMAT_STRING: This is a string that determines the format of the branch name
75
- that is formulated. The following is a list of required placeholders you must put
76
- in your format string to format the branch name: [%t, %d].
77
- \x5Where %t will be replaced by the ticket.
78
- \x5Where %d will be replaced by the ticket description.
79
- \x5The following is a list of optional placeholders you may put
80
- in your format string to format the branch name: [%u].
81
- \x5Where %u will be replaced with your username (`Etc.getlogin`, https://rubygems.org/gems/etc).
82
- \x5The default format string is: "#{DEFAULT_BRANCH_NAME_OPTIONS['create']['format_string']}".
79
+ that is formulated. The following is a list of required placeholders you must put
80
+ 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
84
+ 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']}".
83
87
  LONG_DESC
84
88
  method_option :downcase, type: :boolean, aliases: '-d'
85
89
  method_option :separator, type: :string, aliases: '-s'
@@ -87,6 +91,7 @@ module Branch
87
91
  method_option :project, type: :boolean, aliases: '-p'
88
92
  method_option :project_location, type: :string, aliases: '-l'
89
93
  method_option :project_files, type: :array, aliases: '-f'
94
+ method_option :interactive, type: :boolean, aliases: '-i'
90
95
 
91
96
  def create(ticket_description, ticket = nil)
92
97
  if ticket_description.blank?
@@ -108,11 +113,13 @@ module Branch
108
113
  say_error error.message
109
114
  exit 1
110
115
  end
111
- project_folder = project_folder_for branch_name
112
- unless yes? "Create project for branch \"#{branch_name}\" " \
113
- "in folder \"#{project_folder}\" (y/n)?", :cyan
114
- say 'Aborted.', ABORTED
115
- return
116
+ if options[:interactive]
117
+ project_folder = project_folder_for branch_name
118
+ unless yes? "Create project for branch \"#{branch_name}\" " \
119
+ "in folder \"#{project_folder}\" (y/n)?", :cyan
120
+ say 'Aborted.', ABORTED
121
+ return
122
+ end
116
123
  end
117
124
 
118
125
  say "Project folder name: \"#{project_folder_name}\"", :cyan
@@ -22,7 +22,8 @@ module Branch
22
22
  'format_string' => '%t %d',
23
23
  'project' => false,
24
24
  'project_location' => "#{Locatable.project_folder}/branch-name/projects/%Y/%m (%B)",
25
- 'project_files' => %w[readme.txt scratch.rb snippets.rb]
25
+ 'project_files' => %w[readme.txt scratch.rb snippets.rb],
26
+ 'interactive' => true
26
27
  }
27
28
  }.freeze
28
29
  # rubocop:enable Style/StringHashKeys
@@ -16,7 +16,7 @@ module Branch
16
16
  # Acceptable project folder token separators. If options[:separator]
17
17
  # returns one of these acceptable values, it will be used; otherwise
18
18
  # DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR will be used.
19
- PROJECT_FOLDER_TOKEN_SEPARATORS = %W[- _]
19
+ PROJECT_FOLDER_TOKEN_SEPARATORS = %w[- _].freeze
20
20
 
21
21
  # The default project folder token separator if options[:separator] is
22
22
  # not an acceptable project folder token separator
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
+ require 'thor_nested_subcommand'
4
5
  require_relative '../configurable'
5
6
  require_relative '../exitable'
6
- require_relative 'nestable'
7
7
  require_relative '../task_defaultable'
8
8
 
9
9
  module Branch
@@ -12,8 +12,8 @@ module Branch
12
12
  class Delete < ::Thor
13
13
  include Configurable
14
14
  include Exitable
15
- include Nestable
16
15
  include TaskDefaultable
16
+ include ThorNestedSubcommand
17
17
 
18
18
  class << self
19
19
  def base_usage
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
+ require 'thor_nested_subcommand'
4
5
  require_relative '../configurable'
5
6
  require_relative '../exitable'
6
- require_relative 'nestable'
7
7
  require_relative '../task_defaultable'
8
8
 
9
9
  module Branch
@@ -12,8 +12,8 @@ module Branch
12
12
  class Init < ::Thor
13
13
  include Configurable
14
14
  include Exitable
15
- include Nestable
16
15
  include TaskDefaultable
16
+ include ThorNestedSubcommand
17
17
 
18
18
  class << self
19
19
  def base_usage
@@ -3,6 +3,6 @@
3
3
  module Branch
4
4
  module Name
5
5
  # branch-name version
6
- VERSION = '3.5.1'
6
+ VERSION = '3.7.0'
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.5.1
4
+ version: 3.7.0
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: 2022-10-05 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,6 +84,20 @@ dependencies:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: 1.2.1
87
+ - !ruby/object:Gem::Dependency
88
+ name: thor_nested_subcommand
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '1.0'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '1.0'
87
101
  description: |2
88
102
  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:
89
103
 
@@ -126,7 +140,6 @@ files:
126
140
  - lib/branch/name/subcommands/config.rb
127
141
  - lib/branch/name/subcommands/delete.rb
128
142
  - lib/branch/name/subcommands/init.rb
129
- - lib/branch/name/subcommands/nestable.rb
130
143
  - lib/branch/name/task_defaultable.rb
131
144
  - lib/branch/name/version.rb
132
145
  - sig/branch/name.rbs
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Branch
4
- module Name
5
- module Subcommands
6
- # This module fixes a bug in Thor that prohibits help for nested
7
- # subcommands from displaying help properly. Nested subcommands fail
8
- # to display their subcommand ancestor command name. This fixes that
9
- # bug.
10
- module Nestable
11
- class << self
12
- def included(base)
13
- base.extend ClassMethods
14
- end
15
- end
16
-
17
- module ClassMethods
18
- def base_usage
19
- raise NotImplementedError
20
- end
21
-
22
- # Thor override
23
- # rubocop:disable Style/OptionHash
24
- def desc(usage, description, options = {})
25
- super "#{base_usage} #{usage} ", description, options
26
- end
27
- # rubocop:enable Style/OptionHash
28
-
29
- # Thor override
30
- # rubocop:disable Style/GlobalVars
31
- # rubocop:disable Lint/UnusedMethodArgument
32
- # rubocop:disable Style/OptionalBooleanParameter
33
- def banner(command, namespace = nil, subcommand = false)
34
- command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |_formatted_usage|
35
- "#{basename} #{command.usage}"
36
- end.join("\n")
37
- end
38
- # rubocop:enable Style/GlobalVars
39
- # rubocop:enable Lint/UnusedMethodArgument
40
- # rubocop:enable Style/OptionalBooleanParameter
41
- end
42
- end
43
- end
44
- end
45
- end