branch-name 3.10.3 → 3.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +30 -18
- data/bin/console +0 -1
- data/exe/branch-name +1 -1
- data/lib/.env.development +1 -0
- data/lib/branch/name/cli.rb +11 -18
- data/lib/branch/name/models/branch.rb +31 -0
- data/lib/branch/name/services/branch_name_service.rb +52 -0
- data/lib/branch/name/version.rb +1 -1
- data/lib/branch/name.rb +13 -1
- metadata +7 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7a0395786139641cf06c3d89663980e7b9d1e04add54f5140101255a7fce6f9
|
4
|
+
data.tar.gz: 1a6ab663fea24b03573c152247ca0c1b6a681c5de64ac64223edcf2f90e03f67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e5869f8ab9afb59269db6a5453cbee596a5a61c6822c30f8aa8441634822e4d9c23182f8dde495f583b072da903d5139f9c755670122a3ae1d80744c3b23d3e
|
7
|
+
data.tar.gz: a3eda29aedcbf7a574c6c622905b62c7166c02508d7e0796ee041e47841e10f36dfff4f406c99b2bfa85b2bf72cda98aa77957a93019c893c062218dd9bcd85b
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -5,11 +5,14 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in branch-name.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
gem 'dotenv', '~> 2.8', '>= 2.8.1'
|
8
9
|
gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
|
9
10
|
gem 'rake', '~> 13.0', '>= 13.0.6'
|
10
11
|
gem 'reek', '~> 6.1', '>= 6.1.4'
|
11
12
|
gem 'rspec', '~> 3.12'
|
13
|
+
gem 'rspec-activemodel-mocks', '~> 1.1'
|
12
14
|
gem 'rubocop', '~> 1.56.0'
|
13
15
|
gem 'rubocop-performance', '~> 1.19'
|
14
16
|
gem 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
|
17
|
+
gem 'shoulda-matchers', '~> 5.3'
|
15
18
|
gem 'simplecov', '~> 0.22.0'
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
branch-name (3.10.
|
5
|
-
activesupport (~> 7.0
|
4
|
+
branch-name (3.10.5)
|
5
|
+
activesupport (~> 7.0.8)
|
6
6
|
colorize (>= 0.8.1, < 1.2.0)
|
7
7
|
os (~> 1.1, >= 1.1.4)
|
8
8
|
thor (~> 1.2, >= 1.2.2)
|
@@ -11,7 +11,9 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
|
14
|
+
activemodel (7.0.8)
|
15
|
+
activesupport (= 7.0.8)
|
16
|
+
activesupport (7.0.8)
|
15
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
18
|
i18n (>= 1.6, < 2)
|
17
19
|
minitest (>= 5.1)
|
@@ -24,16 +26,17 @@ GEM
|
|
24
26
|
concurrent-ruby (1.2.2)
|
25
27
|
diff-lcs (1.5.0)
|
26
28
|
docile (1.4.0)
|
29
|
+
dotenv (2.8.1)
|
27
30
|
i18n (1.14.1)
|
28
31
|
concurrent-ruby (~> 1.0)
|
29
32
|
json (2.6.3)
|
30
33
|
kwalify (0.7.2)
|
31
34
|
language_server-protocol (3.17.0.3)
|
32
35
|
method_source (1.0.0)
|
33
|
-
minitest (5.
|
36
|
+
minitest (5.20.0)
|
34
37
|
os (1.1.4)
|
35
38
|
parallel (1.23.0)
|
36
|
-
parser (3.2.2.
|
39
|
+
parser (3.2.2.4)
|
37
40
|
ast (~> 2.4.1)
|
38
41
|
racc
|
39
42
|
pry (0.14.2)
|
@@ -42,19 +45,23 @@ GEM
|
|
42
45
|
pry-byebug (3.10.1)
|
43
46
|
byebug (~> 11.0)
|
44
47
|
pry (>= 0.13, < 0.15)
|
45
|
-
racc (1.7.
|
48
|
+
racc (1.7.2)
|
46
49
|
rainbow (3.1.1)
|
47
|
-
rake (13.0
|
50
|
+
rake (13.1.0)
|
48
51
|
reek (6.1.4)
|
49
52
|
kwalify (~> 0.7.0)
|
50
53
|
parser (~> 3.2.0)
|
51
54
|
rainbow (>= 2.0, < 4.0)
|
52
|
-
regexp_parser (2.8.
|
55
|
+
regexp_parser (2.8.2)
|
53
56
|
rexml (3.2.6)
|
54
57
|
rspec (3.12.0)
|
55
58
|
rspec-core (~> 3.12.0)
|
56
59
|
rspec-expectations (~> 3.12.0)
|
57
60
|
rspec-mocks (~> 3.12.0)
|
61
|
+
rspec-activemodel-mocks (1.1.0)
|
62
|
+
activemodel (>= 3.0)
|
63
|
+
activesupport (>= 3.0)
|
64
|
+
rspec-mocks (>= 2.99, < 4.0)
|
58
65
|
rspec-core (3.12.2)
|
59
66
|
rspec-support (~> 3.12.0)
|
60
67
|
rspec-expectations (3.12.3)
|
@@ -64,7 +71,7 @@ GEM
|
|
64
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
72
|
rspec-support (~> 3.12.0)
|
66
73
|
rspec-support (3.12.1)
|
67
|
-
rubocop (1.56.
|
74
|
+
rubocop (1.56.4)
|
68
75
|
base64 (~> 0.1.1)
|
69
76
|
json (~> 2.3)
|
70
77
|
language_server-protocol (>= 3.17.0)
|
@@ -76,31 +83,33 @@ GEM
|
|
76
83
|
rubocop-ast (>= 1.28.1, < 2.0)
|
77
84
|
ruby-progressbar (~> 1.7)
|
78
85
|
unicode-display_width (>= 2.4.0, < 3.0)
|
79
|
-
rubocop-ast (1.
|
86
|
+
rubocop-ast (1.30.0)
|
80
87
|
parser (>= 3.2.1.0)
|
81
|
-
rubocop-capybara (2.
|
88
|
+
rubocop-capybara (2.19.0)
|
82
89
|
rubocop (~> 1.41)
|
83
|
-
rubocop-factory_bot (2.
|
90
|
+
rubocop-factory_bot (2.24.0)
|
84
91
|
rubocop (~> 1.33)
|
85
|
-
rubocop-performance (1.19.
|
92
|
+
rubocop-performance (1.19.1)
|
86
93
|
rubocop (>= 1.7.0, < 2.0)
|
87
94
|
rubocop-ast (>= 0.4.0)
|
88
|
-
rubocop-rspec (2.
|
89
|
-
rubocop (~> 1.
|
95
|
+
rubocop-rspec (2.25.0)
|
96
|
+
rubocop (~> 1.40)
|
90
97
|
rubocop-capybara (~> 2.17)
|
91
98
|
rubocop-factory_bot (~> 2.22)
|
92
99
|
ruby-progressbar (1.13.0)
|
100
|
+
shoulda-matchers (5.3.0)
|
101
|
+
activesupport (>= 5.2.0)
|
93
102
|
simplecov (0.22.0)
|
94
103
|
docile (~> 1.1)
|
95
104
|
simplecov-html (~> 0.11)
|
96
105
|
simplecov_json_formatter (~> 0.1)
|
97
106
|
simplecov-html (0.12.3)
|
98
107
|
simplecov_json_formatter (0.1.4)
|
99
|
-
thor (1.
|
100
|
-
thor_nested_subcommand (1.0.
|
108
|
+
thor (1.3.0)
|
109
|
+
thor_nested_subcommand (1.0.2)
|
101
110
|
tzinfo (2.0.6)
|
102
111
|
concurrent-ruby (~> 1.0)
|
103
|
-
unicode-display_width (2.
|
112
|
+
unicode-display_width (2.5.0)
|
104
113
|
|
105
114
|
PLATFORMS
|
106
115
|
x86_64-darwin-19
|
@@ -109,13 +118,16 @@ PLATFORMS
|
|
109
118
|
|
110
119
|
DEPENDENCIES
|
111
120
|
branch-name!
|
121
|
+
dotenv (~> 2.8, >= 2.8.1)
|
112
122
|
pry-byebug (~> 3.10, >= 3.10.1)
|
113
123
|
rake (~> 13.0, >= 13.0.6)
|
114
124
|
reek (~> 6.1, >= 6.1.4)
|
115
125
|
rspec (~> 3.12)
|
126
|
+
rspec-activemodel-mocks (~> 1.1)
|
116
127
|
rubocop (~> 1.56.0)
|
117
128
|
rubocop-performance (~> 1.19)
|
118
129
|
rubocop-rspec (~> 2.23, >= 2.23.2)
|
130
|
+
shoulda-matchers (~> 5.3)
|
119
131
|
simplecov (~> 0.22.0)
|
120
132
|
|
121
133
|
BUNDLED WITH
|
data/bin/console
CHANGED
data/exe/branch-name
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
BRANCH_NAME_ENV=development
|
data/lib/branch/name/cli.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative 'loadable'
|
|
11
11
|
require_relative 'locatable'
|
12
12
|
require_relative 'normalizable'
|
13
13
|
require_relative 'projectable'
|
14
|
+
require_relative 'services/branch_name_service'
|
14
15
|
require_relative 'subcommands/config'
|
15
16
|
require_relative 'task_defaultable'
|
16
17
|
require_relative 'version'
|
@@ -25,10 +26,15 @@ module Branch
|
|
25
26
|
include Exitable
|
26
27
|
include Loadable
|
27
28
|
include Locatable
|
28
|
-
include Normalizable
|
29
29
|
include Projectable
|
30
30
|
include TaskDefaultable
|
31
31
|
|
32
|
+
class << self
|
33
|
+
def exit_on_failure?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
32
38
|
class_option :debug, type: :boolean, default: false
|
33
39
|
class_option :verbose, type: :boolean, default: false
|
34
40
|
|
@@ -93,11 +99,9 @@ module Branch
|
|
93
99
|
method_option :interactive, type: :boolean, optional: true, aliases: '-i'
|
94
100
|
|
95
101
|
def create(ticket_description, ticket = nil)
|
96
|
-
validate_ticket_description! ticket_description
|
97
102
|
original_options, altered_options = init_options_for! command: :create
|
98
103
|
self.options = altered_options
|
99
|
-
|
100
|
-
branch_name = validate_and_normalize_branch_name(ticket_description, ticket)
|
104
|
+
branch_name = BranchNameService.new(description: ticket_description, ticket: ticket, options: options).call
|
101
105
|
say "Branch name: \"#{branch_name}\"", :cyan
|
102
106
|
say "Branch name \"#{branch_name}\" has been copied to the clipboard!", SUCCESS if copy_to_clipboard branch_name
|
103
107
|
if original_options[:interactive] && !options[:project]
|
@@ -121,6 +125,9 @@ module Branch
|
|
121
125
|
say "Project folder name: \"#{project_folder_name}\"", :cyan
|
122
126
|
create_project!(project_folder_name)
|
123
127
|
end
|
128
|
+
rescue ArgumentError => e
|
129
|
+
say_error e.message, ERROR
|
130
|
+
exit 1
|
124
131
|
end
|
125
132
|
|
126
133
|
desc 'config SUBCOMMAND', 'Manages config files for this gem'
|
@@ -133,20 +140,6 @@ module Branch
|
|
133
140
|
|
134
141
|
private
|
135
142
|
|
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
143
|
def validate_and_create_project_folder_name_from!(branch_name)
|
151
144
|
project_folder_name_from(branch_name) do |error|
|
152
145
|
say_error error.message
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_model'
|
4
|
+
|
5
|
+
module Branch
|
6
|
+
module Name
|
7
|
+
module Models
|
8
|
+
attr_reader :description, :ticket
|
9
|
+
|
10
|
+
class Branch
|
11
|
+
include ActiveModel::Model
|
12
|
+
|
13
|
+
attr_accessor :description, :ticket
|
14
|
+
|
15
|
+
validates :description, presence: true
|
16
|
+
|
17
|
+
def initialize(description:, ticket: nil, options: {})
|
18
|
+
@description = description
|
19
|
+
@ticket = ticket
|
20
|
+
@options = options
|
21
|
+
|
22
|
+
super description: description, ticket: ticket
|
23
|
+
end
|
24
|
+
|
25
|
+
def branch_name
|
26
|
+
''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../colorizable'
|
4
|
+
require_relative '../normalizable'
|
5
|
+
|
6
|
+
module Branch
|
7
|
+
module Name
|
8
|
+
class BranchNameService
|
9
|
+
include Colorizable
|
10
|
+
include Normalizable
|
11
|
+
|
12
|
+
def initialize(description:, ticket: nil, options: {})
|
13
|
+
@description = description
|
14
|
+
@ticket = ticket
|
15
|
+
@options = options
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
validate_description!
|
20
|
+
@branch_name = normalize_branch_name!
|
21
|
+
validate_banch_name!
|
22
|
+
@branch_name
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :options
|
28
|
+
|
29
|
+
def normalize_branch_name!
|
30
|
+
normalize_branch_name(@description, @ticket) do |error|
|
31
|
+
raise ArgumentError, error.message
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate_description!
|
36
|
+
return unless @description.blank?
|
37
|
+
|
38
|
+
raise ArgumentError, 'description is required'
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate_banch_name!
|
42
|
+
return unless @branch_name.blank?
|
43
|
+
|
44
|
+
raise ArgumentError, invalid_branch_name_message
|
45
|
+
end
|
46
|
+
|
47
|
+
def invalid_branch_name_message
|
48
|
+
'the combination of description/ticket resulted in an empty branch name'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/branch/name/version.rb
CHANGED
data/lib/branch/name.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
|
5
|
+
if File.exist?("#{__dir__}/lib/.env.development")
|
6
|
+
# This loads our development environment when running dev.
|
7
|
+
require 'dotenv'
|
8
|
+
Dotenv.load('.env.development')
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'pry-byebug' if ENV['BRANCH_NAME_ENV'] == 'development'
|
12
|
+
|
13
|
+
Dir.glob("#{__dir__}/name/**/*.rb").each do |file|
|
14
|
+
require file
|
15
|
+
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.
|
4
|
+
version: 3.10.5
|
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-
|
11
|
+
date: 2023-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 7.0.4
|
19
|
+
version: 7.0.8
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 7.0.4
|
26
|
+
version: 7.0.8
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: colorize
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +130,7 @@ files:
|
|
136
130
|
- bin/console
|
137
131
|
- bin/setup
|
138
132
|
- exe/branch-name
|
133
|
+
- lib/.env.development
|
139
134
|
- lib/branch/name.rb
|
140
135
|
- lib/branch/name/cli.rb
|
141
136
|
- lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
|
@@ -145,9 +140,11 @@ files:
|
|
145
140
|
- lib/branch/name/exitable.rb
|
146
141
|
- lib/branch/name/loadable.rb
|
147
142
|
- lib/branch/name/locatable.rb
|
143
|
+
- lib/branch/name/models/branch.rb
|
148
144
|
- lib/branch/name/normalizable.rb
|
149
145
|
- lib/branch/name/option_error.rb
|
150
146
|
- lib/branch/name/projectable.rb
|
147
|
+
- lib/branch/name/services/branch_name_service.rb
|
151
148
|
- lib/branch/name/subcommands/config.rb
|
152
149
|
- lib/branch/name/subcommands/delete.rb
|
153
150
|
- lib/branch/name/subcommands/init.rb
|