branch-name 3.5.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3591154bdf0c66a468e6d3d9d6fc06eab5a6a26f1d08abd193c0d9edbdec38c
4
- data.tar.gz: b07809b34114ec1ac53a36934d1e2c81530e9ab3f8f7c08bdfb6c1353d99b86d
3
+ metadata.gz: 6eaa01fba6e3bd5d848e9ddc6e349f9e9d1f4fd0261e181cc82e78cb68c3e286
4
+ data.tar.gz: 2abb17e38a16bc28fc8690ea1aa805fb04171982bba7e047250e88cad137088a
5
5
  SHA512:
6
- metadata.gz: 0d66fb0d787e92b8747bc8d3defbe1bba52930118e03a8eef7eeb910632239a046825876ef3a1bde27e65943767792b72925dab6281601c95208d99746619564
7
- data.tar.gz: 0772f605b9f5995a442c970199011ebdbe73da4a92b6521e6d92b7d7b62fbe4f7861d868bdd8ab91c71870378373b1caa4759e2caf91ae6cdb37c459579f7e38
6
+ metadata.gz: 9b192d2562ca49009723cc1c1f7f6493ad7df71f35ec07ad47021c5ffa1f27a22fdcd2826ff39539437a0be87d7f6a4b33f1afd766a09d04f614a4dff8b3ec2f
7
+ data.tar.gz: 744f98d3f15956db6265aa560aa59ea3036060fd006141a08755b2c6b0b9746a54cc302013f4d3bc56a4c7dc161135c8cef41505c7e8b37f42426cfa6c855ad4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
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
+
1
10
  ## ['3.5.0'] - 2022-10-04
2
11
  * Changes
3
12
  * Fix broken link to CHANGELOG.md in .gemspec file.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.5.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
 
@@ -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.5.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.5.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: