branch-name 3.2.2 → 3.4.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/lib/branch/name/cli.rb +13 -7
- data/lib/branch/name/colorizable.rb +12 -0
- data/lib/branch/name/configurable.rb +35 -5
- data/lib/branch/name/normalizable.rb +4 -1
- data/lib/branch/name/projectable.rb +16 -4
- data/lib/branch/name/subcommands/config.rb +3 -11
- data/lib/branch/name/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b538070d81c24a53a841d1502a2e846fde4c9349df8f627be5ec21cc133f3446
|
4
|
+
data.tar.gz: 26db98632c66f0d0a020219c4e0f34877d22a71ba741fcabbb42b63f2be5a131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9534c3a6f80ed67115a2e7c2c44651212d7c32e7b7b41d6319ab90da0e978f063faa8f22940d84c6da139237a3a01dcad176eca49a618ee2d9b2673295add1b2
|
7
|
+
data.tar.gz: d8d9a7ac27d35525a0981e85b094c45841893f3c6a70f1fd2eccaabbac8345a50726e456b53e6942f0f45eee31392ffffb495813963f50b4530c690106831418
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## ['3.4.0'] - 2022-10-04
|
2
|
+
* Changes
|
3
|
+
* `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.
|
4
|
+
* Various changes in information printed to stdout when (for example) creating projects.
|
5
|
+
|
6
|
+
## ['3.3.0'] - 2022-09-27
|
7
|
+
* Enhancements:
|
8
|
+
* `branch-name config info` now displays the contents of both the Global and the local config files.
|
9
|
+
|
1
10
|
## ['3.2.2'] - 2022-09-27
|
2
11
|
* Changes:
|
3
12
|
* Refactor code that patches Thor incorrect display of nested commands (subcommangs).
|
data/Gemfile.lock
CHANGED
data/lib/branch/name/cli.rb
CHANGED
@@ -90,7 +90,7 @@ module Branch
|
|
90
90
|
|
91
91
|
def create(ticket_description, ticket = nil)
|
92
92
|
if ticket_description.blank?
|
93
|
-
say_error 'description is required',
|
93
|
+
say_error 'description is required', ERROR
|
94
94
|
exit 1
|
95
95
|
end
|
96
96
|
|
@@ -100,18 +100,24 @@ module Branch
|
|
100
100
|
say_error error.message
|
101
101
|
exit 1
|
102
102
|
end
|
103
|
-
say "Branch name: #{branch_name}", :cyan
|
103
|
+
say "Branch name: \"#{branch_name}\"", :cyan
|
104
|
+
say "Branch name \"#{branch_name}\" has been copied to the clipboard!", SUCCESS if copy_to_clipboard branch_name
|
104
105
|
|
105
106
|
if options[:project]
|
106
|
-
|
107
|
+
project_folder_name = project_folder_name_from(branch_name) do |error|
|
107
108
|
say_error error.message
|
108
109
|
exit 1
|
109
110
|
end
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
+
end
|
113
117
|
|
114
|
-
|
118
|
+
say "Project folder name: \"#{project_folder_name}\"", :cyan
|
119
|
+
create_project!(project_folder_name)
|
120
|
+
end
|
115
121
|
end
|
116
122
|
|
117
123
|
desc 'config SUBCOMMAND', 'Manages config files for this gem'
|
@@ -3,14 +3,17 @@
|
|
3
3
|
require 'colorize'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'yaml'
|
6
|
+
require_relative 'colorizable'
|
6
7
|
require_relative 'locatable'
|
7
8
|
|
8
9
|
module Branch
|
9
10
|
module Name
|
10
11
|
module Configurable
|
12
|
+
include Colorizable
|
11
13
|
include Locatable
|
12
14
|
|
13
15
|
CONFIG_FILENAME = '.branch-name'
|
16
|
+
|
14
17
|
# rubocop:disable Style/StringHashKeys - YAML writing/loading necessitates this
|
15
18
|
DEFAULT_BRANCH_NAME_OPTIONS = {
|
16
19
|
'create' => {
|
@@ -44,10 +47,12 @@ module Branch
|
|
44
47
|
|
45
48
|
def create_global_config_file!
|
46
49
|
create_config_file global_config_file
|
50
|
+
print_global_config_file
|
47
51
|
end
|
48
52
|
|
49
53
|
def create_local_config_file!
|
50
54
|
create_config_file local_config_file
|
55
|
+
print_local_config_file
|
51
56
|
end
|
52
57
|
|
53
58
|
def delete_global_config_file!
|
@@ -58,37 +63,62 @@ module Branch
|
|
58
63
|
delete_config_file local_config_file
|
59
64
|
end
|
60
65
|
|
66
|
+
def print_global_config_file
|
67
|
+
config_file = global_config_file
|
68
|
+
if global_config_file?
|
69
|
+
say "Global config file (#{config_file}) contents:", SUCCESS
|
70
|
+
print_config_file config_file
|
71
|
+
else
|
72
|
+
say "Global config file (#{config_file}) does not exist.", WARNING
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def print_local_config_file
|
77
|
+
config_file = local_config_file
|
78
|
+
if local_config_file?
|
79
|
+
say "Local config file (#{config_file}) contents:", SUCCESS
|
80
|
+
print_config_file config_file
|
81
|
+
else
|
82
|
+
say "Local config file (#{config_file}) does not exist.", WARNING
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
61
86
|
private
|
62
87
|
|
63
88
|
def create_config_file(config_file)
|
64
89
|
folder = File.dirname(config_file)
|
65
90
|
unless Dir.exist?(folder)
|
66
|
-
say "Destination folder for configuration file (#{folder}) does not exist"
|
91
|
+
say "Destination folder for configuration file (#{folder}) does not exist", ERROR
|
67
92
|
return false
|
68
93
|
end
|
69
94
|
|
70
95
|
if File.exist?(config_file)
|
71
|
-
|
96
|
+
say "Configuration file (#{config_file}) already exists", WARNING
|
72
97
|
return false
|
73
98
|
end
|
74
99
|
|
75
100
|
File.write(config_file, DEFAULT_BRANCH_NAME_OPTIONS.to_yaml)
|
76
|
-
|
101
|
+
say "Configuration file (#{config_file}) created.", SUCCESS
|
77
102
|
|
78
103
|
true
|
79
104
|
end
|
80
105
|
|
81
106
|
def delete_config_file(config_file)
|
82
107
|
unless File.exist?(config_file)
|
83
|
-
|
108
|
+
say "Configuration file (#{config_file}) does not exist", WARNING
|
84
109
|
return false
|
85
110
|
end
|
86
111
|
|
87
112
|
File.delete config_file
|
88
|
-
|
113
|
+
say "Configuration file (#{config_file}) deleted", SUCCESS
|
89
114
|
|
90
115
|
true
|
91
116
|
end
|
117
|
+
|
118
|
+
def print_config_file(config_file)
|
119
|
+
hash = YAML.safe_load(File.open(config_file))
|
120
|
+
say hash.to_yaml.gsub("\n-", "\n\n-"), SUCCESS
|
121
|
+
end
|
92
122
|
end
|
93
123
|
end
|
94
124
|
end
|
@@ -25,7 +25,10 @@ module Branch
|
|
25
25
|
yield e
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
# Returns a project folder name from a normalized branch name.
|
29
|
+
# The location of the folder is not included; that is, the
|
30
|
+
# folder returned is not fully qualified.
|
31
|
+
def project_folder_name_from(normalized_branch_name)
|
29
32
|
normalize_token normalized_branch_name, PROJECT_FOLDER_REGEX
|
30
33
|
rescue Branch::Name::OptionError => e
|
31
34
|
raise unless block_given?
|
@@ -11,8 +11,7 @@ module Branch
|
|
11
11
|
def create_project!(branch_name)
|
12
12
|
raise 'options[:project] is false' unless options[:project]
|
13
13
|
|
14
|
-
|
15
|
-
project_folder = "#{project_location}/#{branch_name}"
|
14
|
+
project_folder = project_folder_for branch_name
|
16
15
|
|
17
16
|
if Dir.exist? project_folder
|
18
17
|
puts "Project folder \"#{project_folder}\" already exists"
|
@@ -23,7 +22,15 @@ module Branch
|
|
23
22
|
FileUtils.mkdir_p(project_folder)
|
24
23
|
create_project_files!(project_folder)
|
25
24
|
|
26
|
-
|
25
|
+
project_files = options[:project_files]
|
26
|
+
if project_files.blank?
|
27
|
+
puts "Project folder \"#{project_folder}\" was created.".green
|
28
|
+
else
|
29
|
+
puts "Project folder \"#{project_folder}\" was created with project files:".green
|
30
|
+
project_files.each do |project_file|
|
31
|
+
puts "- #{project_file}".green
|
32
|
+
end
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
def create_project_files!(project_folder)
|
@@ -40,9 +47,14 @@ module Branch
|
|
40
47
|
next if File.exist? full_file_name
|
41
48
|
|
42
49
|
FileUtils.touch full_file_name
|
43
|
-
puts "Created project file \"#{full_file_name}\""
|
50
|
+
puts "Created project file \"#{full_file_name}\"" if options[:verbose]
|
44
51
|
end
|
45
52
|
end
|
53
|
+
|
54
|
+
def project_folder_for(branch_name)
|
55
|
+
project_location = Time.new.strftime(options[:project_location])
|
56
|
+
"#{project_location}/#{branch_name}"
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
@@ -26,17 +26,9 @@ module Branch
|
|
26
26
|
branch-name config info
|
27
27
|
LONG_DESC
|
28
28
|
def info
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
say "Global config file does not exist at: \"#{global_folder}\"", :yellow
|
33
|
-
end
|
34
|
-
|
35
|
-
if local_config_file?
|
36
|
-
say "Local config file exists: \"#{local_config_file}\"", :green
|
37
|
-
else
|
38
|
-
say "Local config file does not exist at: \"#{local_folder}\"", :yellow
|
39
|
-
end
|
29
|
+
print_global_config_file
|
30
|
+
say ''
|
31
|
+
print_local_config_file
|
40
32
|
end
|
41
33
|
|
42
34
|
desc 'init SUBCOMMAND', 'Sets up config files for this gem'
|
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: 3.
|
4
|
+
version: 3.4.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-
|
11
|
+
date: 2022-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/branch/name/cli.rb
|
111
111
|
- lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
|
112
112
|
- lib/branch/name/clipable.rb
|
113
|
+
- lib/branch/name/colorizable.rb
|
113
114
|
- lib/branch/name/configurable.rb
|
114
115
|
- lib/branch/name/exitable.rb
|
115
116
|
- lib/branch/name/loadable.rb
|