branch-name 2.2.0 → 3.0.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 +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/lib/branch/name/cli.rb +2 -1
- 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/subcommands/config.rb +6 -38
- data/lib/branch/name/subcommands/delete.rb +78 -0
- data/lib/branch/name/subcommands/help_nestable.rb +24 -0
- data/lib/branch/name/subcommands/init.rb +15 -23
- data/lib/branch/name/subcommands/nestable.rb +44 -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: ecf9d15cb3f6a7be37ca9d39377e9d8c103b71557ae26a01dbf19670ce3c9548
|
4
|
+
data.tar.gz: 2ee162f10d1bd5bf48cde5e2d7611241600030098b9e50331472eef08077bbad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7dd261862332096d9dd74d38ade8fd517b72ea07fe867a8d2b2b6cbf367b13e296ce2f8fc35cd9bd2a697e53a51d39edc842ca9ad644a6ece15dcd4e0c0b3ac
|
7
|
+
data.tar.gz: cba46ce2945c423427d1e39930d9695841a0153fa041d61899f90b396a156162a4dcce047f1c04d1b131ce7573aa497b3f351538d8d12f6bc7820fcf2fe39b6e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
## ['3.0.0'] - 2022-09-26
|
2
|
+
* Enhancements:
|
3
|
+
* Changes:
|
4
|
+
* Default default commands to :help.
|
5
|
+
* 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.
|
6
|
+
* Bug Fixes: Not really a branch-name bug, but patched Thor bug that displays nested subcommands incorrectly.
|
7
|
+
|
1
8
|
## ['2.2.0'] - 2022-09-24
|
2
9
|
* 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
|
10
|
+
* 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
11
|
* The `branch-name create :project_location` option string now accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directive.
|
5
12
|
* Add better test coverage, although not what it should be (I'm working on it); this started a "quick and dirty" tool.
|
6
13
|
* `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.**
|
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
|
@@ -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
|
@@ -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,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative '../configurable'
|
5
|
+
require_relative '../exitable'
|
6
|
+
require_relative 'nestable'
|
7
|
+
require_relative '../task_defaultable'
|
8
|
+
|
9
|
+
module Branch
|
10
|
+
module Name
|
11
|
+
module Subcommands
|
12
|
+
class Delete < ::Thor
|
13
|
+
include Configurable
|
14
|
+
include Exitable
|
15
|
+
include Nestable
|
16
|
+
include TaskDefaultable
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def ascestor_name
|
20
|
+
'config delete'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'all', 'Deletes all config files (local and global) for this gem'
|
25
|
+
subcommand_help_override "#{ascestor_name} all"
|
26
|
+
long_desc <<-LONG_DESC
|
27
|
+
NAME
|
28
|
+
\x5
|
29
|
+
`branch-name config delete all` -- will remove the all .branch-name config files.
|
30
|
+
|
31
|
+
SYNOPSIS
|
32
|
+
\x5
|
33
|
+
branch-name config delete all
|
34
|
+
LONG_DESC
|
35
|
+
method_option :all, type: :boolean, aliases: '-a'
|
36
|
+
|
37
|
+
def all
|
38
|
+
delete_global_config_file!
|
39
|
+
delete_local_config_file!
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'global', 'Deletes the global config file for this gem'
|
43
|
+
subcommand_help_override "#{ascestor_name} global"
|
44
|
+
long_desc <<-LONG_DESC
|
45
|
+
NAME
|
46
|
+
\x5
|
47
|
+
`branch-name config delete global` -- will remove the global .branch-name config file.
|
48
|
+
|
49
|
+
SYNOPSIS
|
50
|
+
\x5
|
51
|
+
branch-name config delete global
|
52
|
+
LONG_DESC
|
53
|
+
method_option :global, type: :boolean, aliases: '-g'
|
54
|
+
|
55
|
+
def global
|
56
|
+
delete_global_config_file!
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'local', 'Deletes the local config file for this gem'
|
60
|
+
subcommand_help_override "#{ascestor_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
|
+
method_option :local, type: :boolean, aliases: '-l'
|
71
|
+
|
72
|
+
def local
|
73
|
+
delete_local_config_file!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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.subcommand_help_override "config init help [SUBCOMMAND]"
|
16
|
+
def help(command = nil, subcommand = false)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,63 +3,55 @@
|
|
3
3
|
require 'thor'
|
4
4
|
require_relative '../configurable'
|
5
5
|
require_relative '../exitable'
|
6
|
+
require_relative 'nestable'
|
7
|
+
require_relative '../task_defaultable'
|
6
8
|
|
7
9
|
module Branch
|
8
10
|
module Name
|
9
11
|
module Subcommands
|
10
|
-
# https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config
|
11
12
|
class Init < ::Thor
|
12
13
|
include Configurable
|
13
14
|
include Exitable
|
15
|
+
include Nestable
|
16
|
+
include TaskDefaultable
|
14
17
|
|
15
|
-
|
18
|
+
class << self
|
19
|
+
def ascestor_name
|
20
|
+
'config init'
|
21
|
+
end
|
22
|
+
end
|
16
23
|
|
17
24
|
desc 'global', 'Creates and initializes a .branch-name file in the global folder'
|
25
|
+
subcommand_help_override "#{ascestor_name} global"
|
18
26
|
long_desc <<-LONG_DESC
|
19
27
|
NAME
|
20
28
|
\x5
|
21
|
-
`branch-name init global` -- will create and initialize a .branch-name file
|
29
|
+
`branch-name config init global` -- will create and initialize a .branch-name file
|
22
30
|
in the "#{Locatable.global_folder}" folder.
|
23
31
|
|
24
32
|
SYNOPSIS
|
25
33
|
\x5
|
26
|
-
branch-name init global
|
34
|
+
branch-name config init global
|
27
35
|
LONG_DESC
|
28
36
|
def global
|
29
37
|
create_global_config_file!
|
30
38
|
end
|
31
39
|
|
32
40
|
desc 'local', 'Creates and initializes a .branch-name file in the local folder'
|
41
|
+
subcommand_help_override "#{ascestor_name} local"
|
33
42
|
long_desc <<-LONG_DESC
|
34
43
|
NAME
|
35
44
|
\x5
|
36
|
-
`branch-name init local` -- will create and initialize a .branch-name file
|
45
|
+
`branch-name config init local` -- will create and initialize a .branch-name file
|
37
46
|
in the "#{Locatable.local_folder}" folder.
|
38
47
|
|
39
48
|
SYNOPSIS
|
40
49
|
\x5
|
41
|
-
branch-name init local
|
50
|
+
branch-name config init local
|
42
51
|
LONG_DESC
|
43
52
|
def local
|
44
53
|
create_local_config_file!
|
45
54
|
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
55
|
end
|
64
56
|
end
|
65
57
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'help_nestable'
|
4
|
+
|
5
|
+
module Branch
|
6
|
+
module Name
|
7
|
+
module Subcommands
|
8
|
+
# This module fixes a bug in Thor that prohibits help for nested
|
9
|
+
# subcommands from displaying help properly. Nested subcommands fail
|
10
|
+
# to display their subcommand ancestor command name. This fixes that
|
11
|
+
# bug.
|
12
|
+
module Nestable
|
13
|
+
class << self
|
14
|
+
def included(base)
|
15
|
+
base.extend ClassMethods
|
16
|
+
base.include HelpNestable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def ascestor_name
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
25
|
+
# Thor override
|
26
|
+
def banner(command, _namespace = nil, subcommand = false)
|
27
|
+
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |_formatted_usage|
|
28
|
+
command_name = command.name.to_sym
|
29
|
+
"#{basename} #{@subcommand_help_override[command.usage]}"
|
30
|
+
end.join("\n")
|
31
|
+
end
|
32
|
+
|
33
|
+
def subcommand_help_override(help_string)
|
34
|
+
raise "Thor.desc must be called for \"#{help_string}\" " \
|
35
|
+
'prior to calling .subcommand_help_override' if @usage.blank?
|
36
|
+
|
37
|
+
@subcommand_help_override = {} unless defined? @subcommand_help_override
|
38
|
+
@subcommand_help_override[@usage] = help_string
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.0.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-09-
|
11
|
+
date: 2022-09-26 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
|