story_branch 0.2.4 → 0.2.5
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/bin/git-story-unstart +4 -0
- data/bin/git-unstart +4 -0
- data/bin/story-unstart +4 -0
- data/bin/story_unstart +4 -0
- data/lib/story_branch.rb +51 -29
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71eaa77737e5c7d0b0f33de5bd0f2bddea608b37
|
4
|
+
data.tar.gz: dd9ffd60e2981b7b29f9cc874100407f31d099f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18501105780a33a97970652d34d906722362b7f60b791bee54c26da8cf511d5e28525f2022874fe9c450c4d55b33e45b575910d3da27a6e803987994aed817d0
|
7
|
+
data.tar.gz: ae49ac7b0c07187ab62aa622aa0c416d17e36f89a0ffb0989d778e44b1fa8a615238b9078304414c48f94f3b0af6e8562ea799f032595b9fd6c178bbdc720b0d
|
data/bin/git-unstart
ADDED
data/bin/story-unstart
ADDED
data/bin/story_unstart
ADDED
data/lib/story_branch.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Dominic Wong <dominic.wong.617@gmail.com>
|
6
6
|
# Gabe Hollombe <gabe@neo.com>
|
7
7
|
#
|
8
|
-
# Version: 0.2.
|
8
|
+
# Version: 0.2.5
|
9
9
|
#
|
10
10
|
# ## Description
|
11
11
|
#
|
@@ -191,7 +191,7 @@ module StoryBranch
|
|
191
191
|
end
|
192
192
|
|
193
193
|
puts "Use standard finishing commit message: [y/N]?"
|
194
|
-
commit_message = "[Finishes ##{GitUtils.current_branch_story_parts[:id]}] #{GitUtils.current_branch_story_parts[:
|
194
|
+
commit_message = "[Finishes ##{GitUtils.current_branch_story_parts[:id]}] #{StringUtils.undashed GitUtils.current_branch_story_parts[:title]}"
|
195
195
|
puts commit_message
|
196
196
|
|
197
197
|
if gets.chomp!.downcase == "y"
|
@@ -228,11 +228,19 @@ module StoryBranch
|
|
228
228
|
class StringUtils
|
229
229
|
|
230
230
|
def self.dashed s
|
231
|
-
s.tr(' _
|
231
|
+
s.tr(' _,./:;+&', '-')
|
232
232
|
end
|
233
233
|
|
234
234
|
def self.simple_sanitize s
|
235
|
-
s.tr '\'"%!@#$(){}[]*\\?', ''
|
235
|
+
strip_newlines (s.tr '\'"%!@#$(){}[]*\\?', '')
|
236
|
+
end
|
237
|
+
|
238
|
+
def self.normalised_branch_name s
|
239
|
+
StringUtils.simple_sanitize((StringUtils.dashed s).downcase).squeeze("-")
|
240
|
+
end
|
241
|
+
|
242
|
+
def self.strip_newlines s
|
243
|
+
s.tr "\n", "-"
|
236
244
|
end
|
237
245
|
|
238
246
|
def self.undashed s
|
@@ -248,16 +256,31 @@ module StoryBranch
|
|
248
256
|
end
|
249
257
|
|
250
258
|
def self.is_existing_branch? name
|
251
|
-
# we don't use the Git gem's is_local_branch? because we want to
|
252
|
-
# ignore the id suffix while still avoiding name collisions
|
253
259
|
branch_names.each do |n|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
260
|
+
if Levenshtein.distance(n, name) < 3
|
261
|
+
return true
|
262
|
+
end
|
263
|
+
existing_branch_name = n.match(/(.*)(-[1-9][0-9]+$)/)
|
264
|
+
if existing_branch_name
|
265
|
+
levenshtein_distance = Levenshtein.distance existing_branch_name[1], name
|
266
|
+
if levenshtein_distance < 3
|
267
|
+
return true
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
return false
|
272
|
+
end
|
273
|
+
|
274
|
+
def self.is_existing_story? id
|
275
|
+
branch_names.each do |n|
|
276
|
+
branch_id = n.match(/-[1-9][0-9]+$/)
|
277
|
+
if branch_id
|
278
|
+
if branch_id.to_s == "-#{id}"
|
279
|
+
return true
|
280
|
+
end
|
258
281
|
end
|
259
282
|
end
|
260
|
-
|
283
|
+
false
|
261
284
|
end
|
262
285
|
|
263
286
|
def self.branch_names
|
@@ -275,7 +298,7 @@ module StoryBranch
|
|
275
298
|
def self.current_branch_story_parts
|
276
299
|
matches = current_branch.match(/(.*)-(\d+$)/)
|
277
300
|
if matches.length == 3
|
278
|
-
{
|
301
|
+
{ title: matches[1], id: matches[2] }
|
279
302
|
else
|
280
303
|
nil
|
281
304
|
end
|
@@ -395,7 +418,7 @@ module StoryBranch
|
|
395
418
|
end
|
396
419
|
|
397
420
|
def create_feature_branch story
|
398
|
-
dashed_story_name = StringUtils.
|
421
|
+
dashed_story_name = StringUtils.normalised_branch_name story.name
|
399
422
|
feature_branch_name = nil
|
400
423
|
puts "You are checked out at: #{GitUtils.current_branch}"
|
401
424
|
while feature_branch_name == nil or feature_branch_name == ""
|
@@ -403,29 +426,28 @@ module StoryBranch
|
|
403
426
|
feature_branch_name = readline("Name of feature branch: ", [dashed_story_name])
|
404
427
|
end
|
405
428
|
feature_branch_name.chomp!
|
406
|
-
validate_branch_name feature_branch_name
|
407
|
-
|
408
|
-
|
409
|
-
|
429
|
+
if validate_branch_name feature_branch_name, story.id
|
430
|
+
feature_branch_name_with_story_id = "#{feature_branch_name}-#{story.id}"
|
431
|
+
puts "Creating: #{feature_branch_name_with_story_id} with #{GitUtils.current_branch} as parent"
|
432
|
+
GitUtils.create_branch feature_branch_name_with_story_id
|
433
|
+
end
|
410
434
|
end
|
411
435
|
|
412
436
|
# Branch name validation
|
413
|
-
def validate_branch_name name
|
437
|
+
def validate_branch_name name, id
|
438
|
+
if GitUtils.is_existing_story? id
|
439
|
+
puts "Error: An existing branch has the same story id: #{id}"
|
440
|
+
return false
|
441
|
+
end
|
442
|
+
if GitUtils.is_existing_branch? name
|
443
|
+
puts "Error: This name is very similar to an existing branch. Avoid confusion and use a more unique name."
|
444
|
+
return false
|
445
|
+
end
|
414
446
|
unless valid_branch_name? name
|
415
447
|
puts "Error: #{name}\nis an invalid name."
|
416
448
|
return false
|
417
449
|
end
|
418
|
-
|
419
|
-
unless existing_name_score == -1
|
420
|
-
puts <<-EOD.strip_heredoc
|
421
|
-
Name Collision Error:
|
422
|
-
|
423
|
-
#{name}
|
424
|
-
|
425
|
-
This is too similar to the name of an existing
|
426
|
-
branch, a more unique name is required
|
427
|
-
EOD
|
428
|
-
end
|
450
|
+
true
|
429
451
|
end
|
430
452
|
|
431
453
|
def valid_branch_name? name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: story_branch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Milkins
|
@@ -96,6 +96,10 @@ executables:
|
|
96
96
|
- story-start
|
97
97
|
- git-start
|
98
98
|
- git-story-start
|
99
|
+
- story_unstart
|
100
|
+
- story-unstart
|
101
|
+
- git-unstart
|
102
|
+
- git-story-unstart
|
99
103
|
- story_branch
|
100
104
|
- story-branch
|
101
105
|
- git-story
|
@@ -117,12 +121,16 @@ files:
|
|
117
121
|
- bin/git-story-branch
|
118
122
|
- bin/git-story-finish
|
119
123
|
- bin/git-story-start
|
124
|
+
- bin/git-story-unstart
|
125
|
+
- bin/git-unstart
|
120
126
|
- bin/story-branch
|
121
127
|
- bin/story-finish
|
122
128
|
- bin/story-start
|
129
|
+
- bin/story-unstart
|
123
130
|
- bin/story_branch
|
124
131
|
- bin/story_finish
|
125
132
|
- bin/story_start
|
133
|
+
- bin/story_unstart
|
126
134
|
- lib/story_branch.rb
|
127
135
|
homepage: https://github.com/jasonm23/story_branch
|
128
136
|
licenses:
|