branch-name 2.2.0 → 3.2.1
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 +4 -4
- data/CHANGELOG.md +18 -1
- data/Gemfile.lock +1 -1
- data/README.md +33 -0
- data/lib/branch/name/cli.rb +17 -7
- data/lib/branch/name/configurable.rb +0 -16
- data/lib/branch/name/loadable.rb +0 -1
- data/lib/branch/name/locatable.rb +0 -15
- data/lib/branch/name/normalizable.rb +19 -16
- data/lib/branch/name/subcommands/config.rb +6 -38
- data/lib/branch/name/subcommands/delete.rb +76 -0
- data/lib/branch/name/subcommands/help_nestable.rb +27 -0
- data/lib/branch/name/subcommands/init.rb +19 -23
- data/lib/branch/name/subcommands/nestable.rb +49 -0
- data/lib/branch/name/task_defaultable.rb +14 -0
- data/lib/branch/name/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3968d20d8af29e02e511894c96e66b09965f60fd945efdb42c0454d190ce75
|
4
|
+
data.tar.gz: 3d936e247ea81a147fd4e117ee15a10ffce733557c117060c1ead457c1c0bf13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64bf17dc7a54feffe42ed5195d869291a59689c4cc7a06a0c2329ae3c1dbc86cc3ba08225aa58a30b964cd7c82fb6e55aedb8e121a346b2ddc5602938feb46bd
|
7
|
+
data.tar.gz: 29a1c7a1b64f38ed6404c6c9f87d5c95bc5470d31408362b42b96ceaf9b0ca8958a7d59f8bbab0b06b322734b4326ae55652cf5aa4edbcaf3d35fd5aabef8b57
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
+
## ['3.2.1'] - 2022-09-26
|
2
|
+
* Changes:
|
3
|
+
* Fix rubocop violations.
|
4
|
+
* Miscellaneous mixin refactors.
|
5
|
+
* Bug Fixes: Fix bug that displayed subcommand help incorrectly.
|
6
|
+
|
7
|
+
## ['3.1.0'] - 2022-09-26
|
8
|
+
* Enhancements:
|
9
|
+
* Branch names may now be created using a forward-slash (/). See the README.md file for more information.
|
10
|
+
* 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.
|
11
|
+
|
12
|
+
## ['3.0.0'] - 2022-09-26
|
13
|
+
* Changes:
|
14
|
+
* Default default commands to :help.
|
15
|
+
* 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.
|
16
|
+
* Bug Fixes: Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
|
17
|
+
|
1
18
|
## ['2.2.0'] - 2022-09-24
|
2
19
|
* Enhancements:
|
3
|
-
* 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
|
20
|
+
* 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.
|
4
21
|
* The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
|
5
22
|
* Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
|
6
23
|
* `branch-name create` will now create the PROJECT_LOCATION if it does not exist.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# `branch-name`
|
2
2
|
|
3
|
+
[](https://badge.fury.io/gh/gangelo%2Fbranch-name)
|
4
|
+
|
5
|
+
[](https://badge.fury.io/rb/branch-name)
|
6
|
+
|
7
|
+
[](http://www.rubydoc.info/gems/branch-name/)
|
8
|
+
[](http://www.rubydoc.info/gems/branch-name/)
|
9
|
+
|
10
|
+
[](https://github.com/gangelo/branch-name/issues)
|
11
|
+
|
12
|
+
[](#license)
|
13
|
+
|
3
14
|
`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:
|
4
15
|
|
5
16
|
1. Formulate a git *feature branch name*, given a [jira](https://www.atlassian.com/software/jira) ticket and jira ticket description. **Why? Because I am constantly having to create git feature branch names that are based on jira ticket and jira ticket descriptions.**
|
@@ -82,6 +93,7 @@ NOTE: The below examples will assume the following `global` config file defaults
|
|
82
93
|
create:
|
83
94
|
downcase: false
|
84
95
|
separator: _
|
96
|
+
format_string: "%t %d"
|
85
97
|
project: false
|
86
98
|
project_location: "/Users/<username>/feature-branches/%Y"
|
87
99
|
project_files:
|
@@ -101,6 +113,27 @@ This example simply formulates feature a branch named *Add_create_and_destroy_se
|
|
101
113
|
```shell
|
102
114
|
$ branch-name create "Add #create and #destroy session controller actions"
|
103
115
|
```
|
116
|
+
#### Creating a Branch Name that Contains Forward-Slashes (`/`)
|
117
|
+
|
118
|
+
This can be accomplished in different ways; here are some examples:
|
119
|
+
|
120
|
+
Embed the forward-slashes using the `--format-string/-x` option:
|
121
|
+
|
122
|
+
```shell
|
123
|
+
$ branch-name create -x "%u/%t %d" "Remove debug code" UX-54321
|
124
|
+
#=> Branch name: <username>/ux-54321-remove-debug-code
|
125
|
+
...
|
126
|
+
```
|
127
|
+
|
128
|
+
Embed the forward-slashes in the ticket description itself. Depending on *where* you want your forward-slashes to appear, you'll have to place them appropriately:
|
129
|
+
|
130
|
+
```shell
|
131
|
+
$ branch-name create "<username>/UX-54321 Remove debug code"
|
132
|
+
#=> Branch name: <username>/ux-54321-remove-debug-code
|
133
|
+
...
|
134
|
+
```
|
135
|
+
|
136
|
+
NOTE: Project folders created (`--project/-p`) will replace any forward-slash with the `create: :separator` option value.
|
104
137
|
|
105
138
|
## Development
|
106
139
|
|
data/lib/branch/name/cli.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'locatable'
|
|
12
12
|
require_relative 'normalizable'
|
13
13
|
require_relative 'projectable'
|
14
14
|
require_relative 'subcommands/config'
|
15
|
+
require_relative 'task_defaultable'
|
15
16
|
require_relative 'version'
|
16
17
|
|
17
18
|
module Branch
|
@@ -26,11 +27,11 @@ module Branch
|
|
26
27
|
include Locatable
|
27
28
|
include Normalizable
|
28
29
|
include Projectable
|
30
|
+
include TaskDefaultable
|
29
31
|
|
30
32
|
class_option :debug, type: :boolean, default: false
|
31
33
|
class_option :verbose, type: :boolean, default: false
|
32
34
|
|
33
|
-
default_task :create
|
34
35
|
map %w[--version -v] => :version
|
35
36
|
|
36
37
|
desc 'create [OPTIONS] DESCRIPTION [TICKET]', 'Formulate a branch name based on a ticket
|
@@ -71,11 +72,14 @@ module Branch
|
|
71
72
|
The default is: "#{Locatable.project_folder(options: options)}".
|
72
73
|
|
73
74
|
\x5 -x FORMAT_STRING: This is a string that determines the format of the branch name
|
74
|
-
that is formulated. The following
|
75
|
-
in your format string to format the
|
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].
|
76
77
|
\x5Where %t will be replaced by the ticket.
|
77
78
|
\x5Where %d will be replaced by the ticket description.
|
78
|
-
\x5The
|
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
83
|
LONG_DESC
|
80
84
|
method_option :downcase, type: :boolean, aliases: '-d'
|
81
85
|
method_option :separator, type: :string, aliases: '-s'
|
@@ -96,12 +100,18 @@ module Branch
|
|
96
100
|
say_error error.message
|
97
101
|
exit 1
|
98
102
|
end
|
99
|
-
|
100
103
|
say "Branch name: #{branch_name}", :cyan
|
101
104
|
|
102
|
-
|
105
|
+
if options[:project]
|
106
|
+
project_folder = project_folder_from(branch_name) do |error|
|
107
|
+
say_error error.message
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
say "Project folder name: #{project_folder}", :cyan
|
111
|
+
create_project!(project_folder)
|
112
|
+
end
|
103
113
|
|
104
|
-
|
114
|
+
say "Branch name \"#{branch_name}\" has been copied to the clipboard!", :green if copy_to_clipboard branch_name
|
105
115
|
end
|
106
116
|
|
107
117
|
desc 'config SUBCOMMAND', 'Manages config files for this gem'
|
@@ -34,10 +34,6 @@ module Branch
|
|
34
34
|
File.join(local_folder, CONFIG_FILENAME)
|
35
35
|
end
|
36
36
|
|
37
|
-
def system_config_file
|
38
|
-
File.join(system_folder, CONFIG_FILENAME)
|
39
|
-
end
|
40
|
-
|
41
37
|
def global_config_file?
|
42
38
|
File.exist? global_config_file
|
43
39
|
end
|
@@ -46,10 +42,6 @@ module Branch
|
|
46
42
|
File.exist? local_config_file
|
47
43
|
end
|
48
44
|
|
49
|
-
def system_config_file?
|
50
|
-
File.exist? system_config_file
|
51
|
-
end
|
52
|
-
|
53
45
|
def create_global_config_file!
|
54
46
|
create_config_file global_config_file
|
55
47
|
end
|
@@ -58,10 +50,6 @@ module Branch
|
|
58
50
|
create_config_file local_config_file
|
59
51
|
end
|
60
52
|
|
61
|
-
def create_system_config_file!
|
62
|
-
create_config_file system_config_file
|
63
|
-
end
|
64
|
-
|
65
53
|
def delete_global_config_file!
|
66
54
|
delete_config_file global_config_file
|
67
55
|
end
|
@@ -70,10 +58,6 @@ module Branch
|
|
70
58
|
delete_config_file local_config_file
|
71
59
|
end
|
72
60
|
|
73
|
-
def delete_system_config_file!
|
74
|
-
delete_config_file system_config_file
|
75
|
-
end
|
76
|
-
|
77
61
|
private
|
78
62
|
|
79
63
|
def create_config_file(config_file)
|
data/lib/branch/name/loadable.rb
CHANGED
@@ -19,27 +19,12 @@ module Branch
|
|
19
19
|
Dir.pwd
|
20
20
|
end
|
21
21
|
|
22
|
-
def system_folder
|
23
|
-
system_folder = Pathname.new('/')
|
24
|
-
unless system_folder.exist? && system_folder.directory?
|
25
|
-
puts "WARNING: system folder #{system_folder} does not exist, " \
|
26
|
-
"using global folder instead (#{global_folder})".red
|
27
|
-
|
28
|
-
return global_folder
|
29
|
-
end
|
30
|
-
system_folder.to_s
|
31
|
-
end
|
32
|
-
|
33
22
|
def project_folder(options: {})
|
34
23
|
return home_folder if options.blank?
|
35
24
|
|
36
25
|
home_folder
|
37
26
|
end
|
38
27
|
|
39
|
-
def system_folder_equals_global_folder?
|
40
|
-
syetem_folder == global_folder
|
41
|
-
end
|
42
|
-
|
43
28
|
def temp_folder
|
44
29
|
Dir.tmpdir
|
45
30
|
end
|
@@ -5,13 +5,28 @@ require_relative 'option_error'
|
|
5
5
|
module Branch
|
6
6
|
module Name
|
7
7
|
module Normalizable
|
8
|
-
|
8
|
+
# The regex used to split ticket and ticket description tokens
|
9
|
+
# to formulate a source control branch name.
|
10
|
+
BRANCH_NAME_REGEX = %r{[^/\w\x20]}
|
11
|
+
|
12
|
+
# The regex used to split ticket and ticket description tokens
|
13
|
+
# to formulate a project folder based on the branch name formulated.
|
14
|
+
PROJECT_FOLDER_REGEX = /[\W_]/
|
9
15
|
|
10
16
|
def normalize_branch_name(ticket_description, ticket)
|
11
17
|
formatted_branch_name = format_string_or_default
|
12
18
|
formatted_branch_name = formatted_branch_name.gsub('%t', ticket || '')
|
13
19
|
formatted_branch_name = formatted_branch_name.gsub('%d', ticket_description)
|
14
|
-
formatted_branch_name =
|
20
|
+
formatted_branch_name = formatted_branch_name.gsub('%u', Etc.getlogin)
|
21
|
+
normalize_token formatted_branch_name, BRANCH_NAME_REGEX
|
22
|
+
rescue Branch::Name::OptionError => e
|
23
|
+
raise unless block_given?
|
24
|
+
|
25
|
+
yield e
|
26
|
+
end
|
27
|
+
|
28
|
+
def project_folder_from(normalized_branch_name)
|
29
|
+
normalize_token normalized_branch_name, PROJECT_FOLDER_REGEX
|
15
30
|
rescue Branch::Name::OptionError => e
|
16
31
|
raise unless block_given?
|
17
32
|
|
@@ -34,20 +49,8 @@ module Branch
|
|
34
49
|
format_string
|
35
50
|
end
|
36
51
|
|
37
|
-
def
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def normalize_ticket(ticket)
|
42
|
-
return if ticket.blank?
|
43
|
-
|
44
|
-
ticket.split(NON_WORD_CHARS_REGEX).filter_map do |token|
|
45
|
-
normalize_token(token)
|
46
|
-
end.join(options[:separator])
|
47
|
-
end
|
48
|
-
|
49
|
-
def normalize_token(token)
|
50
|
-
token = token.gsub(NON_WORD_CHARS_REGEX, ' ')
|
52
|
+
def normalize_token(token, regex)
|
53
|
+
token = token.gsub(regex, ' ')
|
51
54
|
token = token.strip
|
52
55
|
.squeeze(' ')
|
53
56
|
.split.join(options[:separator])
|
@@ -3,7 +3,9 @@
|
|
3
3
|
require 'thor'
|
4
4
|
require_relative '../configurable'
|
5
5
|
require_relative '../exitable'
|
6
|
+
require_relative 'delete'
|
6
7
|
require_relative 'init'
|
8
|
+
require_relative '../task_defaultable'
|
7
9
|
|
8
10
|
module Branch
|
9
11
|
module Name
|
@@ -11,8 +13,7 @@ module Branch
|
|
11
13
|
class Config < ::Thor
|
12
14
|
include Configurable
|
13
15
|
include Exitable
|
14
|
-
|
15
|
-
default_task :info
|
16
|
+
include TaskDefaultable
|
16
17
|
|
17
18
|
desc 'info', 'Displays information about this gem configuration'
|
18
19
|
long_desc <<-LONG_DESC
|
@@ -36,46 +37,13 @@ module Branch
|
|
36
37
|
else
|
37
38
|
say "Local config file does not exist at: \"#{local_folder}\"", :yellow
|
38
39
|
end
|
39
|
-
|
40
|
-
if system_config_file?
|
41
|
-
say "System config file exists: \"#{system_config_file}\"", :green
|
42
|
-
else
|
43
|
-
say "System config file does not exist at: \"#{system_folder}\"", :yellow
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
desc 'delete [OPTION]', 'Removes .branch-name file(s)'
|
48
|
-
long_desc <<-LONG_DESC
|
49
|
-
NAME
|
50
|
-
\x5
|
51
|
-
`branch-name config delete [OPTION]` -- will remove one or all .branch-name file(s)
|
52
|
-
depending on the OPTION.
|
53
|
-
|
54
|
-
SYNOPSIS
|
55
|
-
\x5
|
56
|
-
branch-name config delete [-a|-g|-l|-s]
|
57
|
-
LONG_DESC
|
58
|
-
method_option :all, type: :boolean, aliases: '-a'
|
59
|
-
method_option :global, type: :boolean, aliases: '-g'
|
60
|
-
method_option :local, type: :boolean, aliases: '-l'
|
61
|
-
method_option :system, type: :boolean, aliases: '-s'
|
62
|
-
|
63
|
-
def delete
|
64
|
-
if options[:all]
|
65
|
-
delete_global_config_file!
|
66
|
-
delete_local_config_file!
|
67
|
-
delete_system_config_file!
|
68
|
-
elsif options[:global]
|
69
|
-
delete_global_config_file!
|
70
|
-
elsif options[:local]
|
71
|
-
delete_local_config_file!
|
72
|
-
elsif options[:system]
|
73
|
-
delete_system_config_file!
|
74
|
-
end
|
75
40
|
end
|
76
41
|
|
77
42
|
desc 'init SUBCOMMAND', 'Sets up config files for this gem'
|
78
43
|
subcommand :init, Branch::Name::Subcommands::Init
|
44
|
+
|
45
|
+
desc 'delete SUBCOMMAND', 'Deletes one of all config files for this gem'
|
46
|
+
subcommand :delete, Branch::Name::Subcommands::Delete
|
79
47
|
end
|
80
48
|
end
|
81
49
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative '../configurable'
|
5
|
+
require_relative '../exitable'
|
6
|
+
require_relative 'help_nestable'
|
7
|
+
require_relative 'nestable'
|
8
|
+
require_relative '../task_defaultable'
|
9
|
+
|
10
|
+
module Branch
|
11
|
+
module Name
|
12
|
+
module Subcommands
|
13
|
+
class Delete < ::Thor
|
14
|
+
include Configurable
|
15
|
+
include Exitable
|
16
|
+
include Nestable
|
17
|
+
include TaskDefaultable
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def ancestor_name
|
21
|
+
'config delete'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# NOTE: This must be included AFTER defining .ancestor_name
|
26
|
+
include HelpNestable
|
27
|
+
|
28
|
+
desc 'all', 'Deletes all config files (local and global) for this gem'
|
29
|
+
help_override "#{ancestor_name} all"
|
30
|
+
long_desc <<-LONG_DESC
|
31
|
+
NAME
|
32
|
+
\x5
|
33
|
+
`branch-name config delete all` -- will remove the all .branch-name config files.
|
34
|
+
|
35
|
+
SYNOPSIS
|
36
|
+
\x5
|
37
|
+
branch-name config delete all
|
38
|
+
LONG_DESC
|
39
|
+
def all
|
40
|
+
delete_global_config_file!
|
41
|
+
delete_local_config_file!
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'global', 'Deletes the global config file for this gem'
|
45
|
+
help_override "#{ancestor_name} global"
|
46
|
+
long_desc <<-LONG_DESC
|
47
|
+
NAME
|
48
|
+
\x5
|
49
|
+
`branch-name config delete global` -- will remove the global .branch-name config file.
|
50
|
+
|
51
|
+
SYNOPSIS
|
52
|
+
\x5
|
53
|
+
branch-name config delete global
|
54
|
+
LONG_DESC
|
55
|
+
def global
|
56
|
+
delete_global_config_file!
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'local', 'Deletes the local config file for this gem'
|
60
|
+
help_override "#{ancestor_name} local"
|
61
|
+
long_desc <<-LONG_DESC
|
62
|
+
NAME
|
63
|
+
\x5
|
64
|
+
`branch-name config delete local` -- will remove the local .branch-name config file.
|
65
|
+
|
66
|
+
SYNOPSIS
|
67
|
+
\x5
|
68
|
+
branch-name config delete local
|
69
|
+
LONG_DESC
|
70
|
+
def local
|
71
|
+
delete_local_config_file!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Branch
|
4
|
+
module Name
|
5
|
+
module Subcommands
|
6
|
+
# This module helps fix 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. This module is used in conjunction with the Nestable module.
|
10
|
+
module HelpNestable
|
11
|
+
class << self
|
12
|
+
def included(base)
|
13
|
+
# Thor override
|
14
|
+
base.desc 'help [COMMAND]', 'Describe available commands or one specific command'
|
15
|
+
base.help_override "#{base.ancestor_name} help [SUBCOMMAND]"
|
16
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
17
|
+
# def help(command = nil, subcommand = false)
|
18
|
+
# puts "subcommand: #{subcommand}"
|
19
|
+
# super
|
20
|
+
# end
|
21
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,63 +3,59 @@
|
|
3
3
|
require 'thor'
|
4
4
|
require_relative '../configurable'
|
5
5
|
require_relative '../exitable'
|
6
|
+
require_relative 'help_nestable'
|
7
|
+
require_relative 'nestable'
|
8
|
+
require_relative '../task_defaultable'
|
6
9
|
|
7
10
|
module Branch
|
8
11
|
module Name
|
9
12
|
module Subcommands
|
10
|
-
# https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config
|
11
13
|
class Init < ::Thor
|
12
14
|
include Configurable
|
13
15
|
include Exitable
|
16
|
+
include Nestable
|
17
|
+
include TaskDefaultable
|
14
18
|
|
15
|
-
|
19
|
+
class << self
|
20
|
+
def ancestor_name
|
21
|
+
'config init'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# NOTE: This must be included AFTER defining .ancestor_name
|
26
|
+
include HelpNestable
|
16
27
|
|
17
28
|
desc 'global', 'Creates and initializes a .branch-name file in the global folder'
|
29
|
+
help_override "#{ancestor_name} global"
|
18
30
|
long_desc <<-LONG_DESC
|
19
31
|
NAME
|
20
32
|
\x5
|
21
|
-
`branch-name init global` -- will create and initialize a .branch-name file
|
33
|
+
`branch-name config init global` -- will create and initialize a .branch-name file
|
22
34
|
in the "#{Locatable.global_folder}" folder.
|
23
35
|
|
24
36
|
SYNOPSIS
|
25
37
|
\x5
|
26
|
-
branch-name init global
|
38
|
+
branch-name config init global
|
27
39
|
LONG_DESC
|
28
40
|
def global
|
29
41
|
create_global_config_file!
|
30
42
|
end
|
31
43
|
|
32
44
|
desc 'local', 'Creates and initializes a .branch-name file in the local folder'
|
45
|
+
help_override "#{ancestor_name} local"
|
33
46
|
long_desc <<-LONG_DESC
|
34
47
|
NAME
|
35
48
|
\x5
|
36
|
-
`branch-name init local` -- will create and initialize a .branch-name file
|
49
|
+
`branch-name config init local` -- will create and initialize a .branch-name file
|
37
50
|
in the "#{Locatable.local_folder}" folder.
|
38
51
|
|
39
52
|
SYNOPSIS
|
40
53
|
\x5
|
41
|
-
branch-name init local
|
54
|
+
branch-name config init local
|
42
55
|
LONG_DESC
|
43
56
|
def local
|
44
57
|
create_local_config_file!
|
45
58
|
end
|
46
|
-
|
47
|
-
desc 'system', 'Creates and initializes a .branch-name file in the system folder'
|
48
|
-
long_desc <<-LONG_DESC
|
49
|
-
NAME
|
50
|
-
\x5
|
51
|
-
`branch-name init system` -- will create and initialize a .branch-name file
|
52
|
-
in the "#{Locatable.system_folder}" folder.
|
53
|
-
|
54
|
-
SYNOPSIS
|
55
|
-
\x5
|
56
|
-
branch-name init system
|
57
|
-
LONG_DESC
|
58
|
-
def system
|
59
|
-
# create_system_config_file!
|
60
|
-
say_error 'System initialization is not available at this time', :red
|
61
|
-
exit 1
|
62
|
-
end
|
63
59
|
end
|
64
60
|
end
|
65
61
|
end
|
@@ -0,0 +1,49 @@
|
|
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 ancestor_name
|
19
|
+
raise NotImplementedError
|
20
|
+
end
|
21
|
+
|
22
|
+
# Thor override
|
23
|
+
# rubocop:disable Style/GlobalVars
|
24
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
25
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
26
|
+
def banner(command, namespace = nil, subcommand = false)
|
27
|
+
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |_formatted_usage|
|
28
|
+
"#{basename} #{@help_override[command.usage]}"
|
29
|
+
end.join("\n")
|
30
|
+
end
|
31
|
+
# rubocop:enable Style/GlobalVars
|
32
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
33
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
34
|
+
|
35
|
+
def help_override(help_string)
|
36
|
+
if @usage.blank?
|
37
|
+
raise 'Thor.desc must be called for the command that should ' \
|
38
|
+
"be associated with \"#{help_string}\" prior to calling " \
|
39
|
+
'.help_override'
|
40
|
+
end
|
41
|
+
|
42
|
+
@help_override = {} unless defined? @help_override
|
43
|
+
@help_override[@usage] = help_string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/branch/name/version.rb
CHANGED
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:
|
4
|
+
version: 3.2.1
|
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-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -118,7 +118,11 @@ files:
|
|
118
118
|
- lib/branch/name/option_error.rb
|
119
119
|
- lib/branch/name/projectable.rb
|
120
120
|
- lib/branch/name/subcommands/config.rb
|
121
|
+
- lib/branch/name/subcommands/delete.rb
|
122
|
+
- lib/branch/name/subcommands/help_nestable.rb
|
121
123
|
- lib/branch/name/subcommands/init.rb
|
124
|
+
- lib/branch/name/subcommands/nestable.rb
|
125
|
+
- lib/branch/name/task_defaultable.rb
|
122
126
|
- lib/branch/name/version.rb
|
123
127
|
- sig/branch/name.rbs
|
124
128
|
homepage: https://github.com/gangelo/branch-name
|