branch-name 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -4
- data/lib/branch/name/cli.rb +35 -28
- data/lib/branch/name/configurable.rb +2 -1
- data/lib/branch/name/normalizable.rb +1 -1
- data/lib/branch/name/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4e1d2055038b5a1dc390420951edc3a1b359f359804b10b8699d67548a0dd2
|
4
|
+
data.tar.gz: d002928e6ede613707e119f3703f7724444e443a607eea8729cd15fda7c9636a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e20a24062daf1a3707fddbb6f809e1753c22e5ab61e8309a394a729f083e93147316b7b8e5fa07e611f82cbb117e41aacc198266fc979169e1b4de74249fd6a
|
7
|
+
data.tar.gz: 3d760194ca03920161ddef676b2d0f12c2519e9350fb5221d6fe667bf79a6965e6bb3c3e3b1e4e24be586d47e8d88acccb63069c87883f07e7990e90476c376d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## ['3.6.0'] - 2022-10-06
|
2
|
+
* Changes
|
3
|
+
* 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.
|
4
|
+
* Update the README.md file accordign to the aforementioned.
|
5
|
+
|
1
6
|
## ['3.5.1'] - 2022-10-05
|
2
7
|
* Bug Fixes
|
3
8
|
* Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,7 @@ NOTE: You can manually change any of the options you wish. It is recommended tha
|
|
76
76
|
|
77
77
|
The `create: project_location` option string also accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directives.
|
78
78
|
|
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,
|
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, particular characters will be stripped to formulate the branch name (see `Branch::Name::Normalizable::BRANCH_NAME_REGEX` which equates to `%r{[^/\w\x20]|_}`).
|
80
80
|
|
81
81
|
Any or all of these options can also be overwritten on the command-line. For more information:
|
82
82
|
`$ branch-name config help init`
|
@@ -100,14 +100,17 @@ create:
|
|
100
100
|
- readme.txt
|
101
101
|
- scratch.rb
|
102
102
|
- snippets.rb
|
103
|
+
interactive: true
|
103
104
|
```
|
104
105
|
|
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
|
106
|
+
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
107
|
|
107
108
|
```shell
|
108
|
-
$ branch-name create -p -d -s - "Pay down tech debt on User model" LG-12345
|
109
|
+
$ branch-name create -i false -p -d -s - "Pay down tech debt on User model" LG-12345
|
109
110
|
```
|
110
111
|
|
112
|
+
NOTE: When creating projects, `branch-name` will prompt you if the `interactive` option is true (`-i`).
|
113
|
+
|
111
114
|
This example simply formulates feature a branch named *Add_create_and_destroy_session_controller_actions* and copies it to the clipboard.
|
112
115
|
|
113
116
|
```shell
|
@@ -133,7 +136,7 @@ $ branch-name create "<username>/UX-54321 Remove debug code"
|
|
133
136
|
...
|
134
137
|
```
|
135
138
|
|
136
|
-
NOTE: Project folders
|
139
|
+
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
140
|
|
138
141
|
## Development
|
139
142
|
|
data/lib/branch/name/cli.rb
CHANGED
@@ -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
|
-
|
54
|
-
|
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
|
-
|
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
|
-
|
67
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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 = %
|
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
|
data/lib/branch/name/version.rb
CHANGED