branch-name 3.4.0 → 3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b538070d81c24a53a841d1502a2e846fde4c9349df8f627be5ec21cc133f3446
4
- data.tar.gz: 26db98632c66f0d0a020219c4e0f34877d22a71ba741fcabbb42b63f2be5a131
3
+ metadata.gz: 6eaa01fba6e3bd5d848e9ddc6e349f9e9d1f4fd0261e181cc82e78cb68c3e286
4
+ data.tar.gz: 2abb17e38a16bc28fc8690ea1aa805fb04171982bba7e047250e88cad137088a
5
5
  SHA512:
6
- metadata.gz: 9534c3a6f80ed67115a2e7c2c44651212d7c32e7b7b41d6319ab90da0e978f063faa8f22940d84c6da139237a3a01dcad176eca49a618ee2d9b2673295add1b2
7
- data.tar.gz: d8d9a7ac27d35525a0981e85b094c45841893f3c6a70f1fd2eccaabbac8345a50726e456b53e6942f0f45eee31392ffffb495813963f50b4530c690106831418
6
+ metadata.gz: 9b192d2562ca49009723cc1c1f7f6493ad7df71f35ec07ad47021c5ffa1f27a22fdcd2826ff39539437a0be87d7f6a4b33f1afd766a09d04f614a4dff8b3ec2f
7
+ data.tar.gz: 744f98d3f15956db6265aa560aa59ea3036060fd006141a08755b2c6b0b9746a54cc302013f4d3bc56a4c7dc161135c8cef41505c7e8b37f42426cfa6c855ad4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## ['3.5.1'] - 2022-10-05
2
+ * Bug Fixes
3
+ * Fix bug that failed to remove underscore (_) characters in ticket and ticket descriptions from folder and branch name formulation.
4
+ * Fix bug that allowed unacceptable project folder token separators in the project folder name (-p option). The rule is now: for `branch-name create`, 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 separator; otherwise, `Branch::Name::Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR` will be used.
5
+ * Changes
6
+ * Add test coverage for the above scenarios.
7
+ * Use File.join to join paths and files safely where appropriate.
8
+ * Update .gemspec gem description with more detail.
9
+
10
+ ## ['3.5.0'] - 2022-10-04
11
+ * Changes
12
+ * Fix broken link to CHANGELOG.md in .gemspec file.
13
+
1
14
  ## ['3.4.0'] - 2022-10-04
2
15
  * Changes
3
16
  * `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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.4.0)
4
+ branch-name (3.5.1)
5
5
  activesupport (~> 7.0, >= 7.0.4)
6
6
  colorize (~> 0.8.1)
7
7
  os (~> 1.1, >= 1.1.4)
data/branch-name.gemspec CHANGED
@@ -9,7 +9,13 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['public.gma@gmail.com']
10
10
 
11
11
  spec.summary = 'Generates a branch name based on a JIRA ticket/ticket number.'
12
- spec.description = 'Generates a branch name based on a JIRA ticket/ticket number.'
12
+ spec.description = <<-EOF
13
+ 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:
14
+
15
+ 1. Formulate a git feature branch name, given a 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.
16
+ 2. Optionally create a "project" based on the branch name (formulated in step 1 above). Why? Because I'm constantly having to create folders to manage files associated with the feature branches I am working on.
17
+ 3. Optionally use and manage default options that determine the git feature branch name formulated, project greated, and default files associated with the project.Why? Because I routinely have to create files to support the feature I am working on and associate them with the feature I am working on. For example: scratch.rb to hold scratch code, snippets.rb to hold code to execute to perform redundant tasks, and readme.txt files to document things I need to remember.
18
+ EOF
13
19
  spec.homepage = 'https://github.com/gangelo/branch-name'
14
20
  spec.license = 'MIT'
15
21
 
@@ -19,7 +25,7 @@ Gem::Specification.new do |spec|
19
25
 
20
26
  spec.metadata['homepage_uri'] = spec.homepage
21
27
  spec.metadata['source_code_uri'] = 'https://github.com/gangelo/branch-name'
22
- spec.metadata['changelog_uri'] = 'https://github.com/gangelo/branch-name/CHANGELOG.md'
28
+ spec.metadata['changelog_uri'] = 'https://github.com/gangelo/branch-name/blob/main/CHANGELOG.md'
23
29
 
24
30
  # Specify which files should be added to the gem when it is released.
25
31
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -7,18 +7,28 @@ module Branch
7
7
  module Normalizable
8
8
  # The regex used to split ticket and ticket description tokens
9
9
  # to formulate a source control branch name.
10
- BRANCH_NAME_REGEX = %r{[^/\w\x20]}
10
+ BRANCH_NAME_REGEX = %r{[^/\w\x20]|_}
11
11
 
12
12
  # The regex used to split ticket and ticket description tokens
13
13
  # to formulate a project folder based on the branch name formulated.
14
14
  PROJECT_FOLDER_REGEX = /[\W_]/
15
15
 
16
+ # Acceptable project folder token separators. If options[:separator]
17
+ # returns one of these acceptable values, it will be used; otherwise
18
+ # DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR will be used.
19
+ PROJECT_FOLDER_TOKEN_SEPARATORS = %W[- _]
20
+
21
+ # The default project folder token separator if options[:separator] is
22
+ # not an acceptable project folder token separator
23
+ # (i.e. PROJECT_FOLDER_TOKEN_SEPARATORS).
24
+ DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR = PROJECT_FOLDER_TOKEN_SEPARATORS.first
25
+
16
26
  def normalize_branch_name(ticket_description, ticket)
17
27
  formatted_branch_name = format_string_or_default
18
28
  formatted_branch_name = formatted_branch_name.gsub('%t', ticket || '')
19
29
  formatted_branch_name = formatted_branch_name.gsub('%d', ticket_description)
20
30
  formatted_branch_name = formatted_branch_name.gsub('%u', Etc.getlogin)
21
- normalize_token formatted_branch_name, BRANCH_NAME_REGEX
31
+ normalize_token formatted_branch_name, BRANCH_NAME_REGEX, options[:separator]
22
32
  rescue Branch::Name::OptionError => e
23
33
  raise unless block_given?
24
34
 
@@ -29,7 +39,7 @@ module Branch
29
39
  # The location of the folder is not included; that is, the
30
40
  # folder returned is not fully qualified.
31
41
  def project_folder_name_from(normalized_branch_name)
32
- normalize_token normalized_branch_name, PROJECT_FOLDER_REGEX
42
+ normalize_token normalized_branch_name, PROJECT_FOLDER_REGEX, project_folder_separator
33
43
  rescue Branch::Name::OptionError => e
34
44
  raise unless block_given?
35
45
 
@@ -52,15 +62,22 @@ module Branch
52
62
  format_string
53
63
  end
54
64
 
55
- def normalize_token(token, regex)
65
+ def normalize_token(token, regex, separator)
56
66
  token = token.gsub(regex, ' ')
57
67
  token = token.strip
58
68
  .squeeze(' ')
59
- .split.join(options[:separator])
60
- token = token.squeeze(options[:separator])
69
+ .split.join(separator)
70
+ token = token.squeeze(separator)
61
71
  token = token.downcase if options[:downcase]
62
72
  token
63
73
  end
74
+
75
+ def project_folder_separator
76
+ separator = options[:separator]
77
+ return options[:separator] if PROJECT_FOLDER_TOKEN_SEPARATORS.include? separator
78
+
79
+ DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR
80
+ end
64
81
  end
65
82
  end
66
83
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require_relative 'locatable'
5
+ require_relative 'normalizable'
5
6
 
6
7
  module Branch
7
8
  module Name
8
9
  module Projectable
9
10
  include Locatable
11
+ include Normalizable
10
12
 
11
13
  def create_project!(branch_name)
12
14
  raise 'options[:project] is false' unless options[:project]
@@ -52,8 +54,9 @@ module Branch
52
54
  end
53
55
 
54
56
  def project_folder_for(branch_name)
57
+ branch_name = project_folder_name_from branch_name
55
58
  project_location = Time.new.strftime(options[:project_location])
56
- "#{project_location}/#{branch_name}"
59
+ File.join(project_location, branch_name)
57
60
  end
58
61
  end
59
62
  end
@@ -3,6 +3,6 @@
3
3
  module Branch
4
4
  module Name
5
5
  # branch-name version
6
- VERSION = '3.4.0'
6
+ VERSION = '3.5.1'
7
7
  end
8
8
  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.4.0
4
+ version: 3.5.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-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,7 +84,12 @@ dependencies:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: 1.2.1
87
- description: Generates a branch name based on a JIRA ticket/ticket number.
87
+ description: |2
88
+ 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:
89
+
90
+ 1. Formulate a git feature branch name, given a 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.
91
+ 2. Optionally create a "project" based on the branch name (formulated in step 1 above). Why? Because I'm constantly having to create folders to manage files associated with the feature branches I am working on.
92
+ 3. Optionally use and manage default options that determine the git feature branch name formulated, project greated, and default files associated with the project.Why? Because I routinely have to create files to support the feature I am working on and associate them with the feature I am working on. For example: scratch.rb to hold scratch code, snippets.rb to hold code to execute to perform redundant tasks, and readme.txt files to document things I need to remember.
88
93
  email:
89
94
  - public.gma@gmail.com
90
95
  executables:
@@ -131,7 +136,7 @@ licenses:
131
136
  metadata:
132
137
  homepage_uri: https://github.com/gangelo/branch-name
133
138
  source_code_uri: https://github.com/gangelo/branch-name
134
- changelog_uri: https://github.com/gangelo/branch-name/CHANGELOG.md
139
+ changelog_uri: https://github.com/gangelo/branch-name/blob/main/CHANGELOG.md
135
140
  rubygems_mfa_required: 'true'
136
141
  post_install_message:
137
142
  rdoc_options: []