git-story-workflow 0.9.12 → 0.10.0

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: d3acae027af5cd4f0b585174804a628ae5f07ab7f5ed81c9cf0f6ea324771317
4
- data.tar.gz: e6df688c535e7877baea001899bdc89f971f317d78c4ce25ab5d3fd64750f66f
3
+ metadata.gz: c0a262c355dd2d101911c442e5e9ba5d12da74967e3db37a600dc5f2f21ed1d9
4
+ data.tar.gz: bfe8ea9f227c933eaec80aae69bef429cac5d76eb311b0ddf40b7bd6247e7779
5
5
  SHA512:
6
- metadata.gz: 3840b6c21619092377f7c9e07dea084a486a1853fe9e872ac1eb0b3008b3a567a8aae706fb0c196c090103c30db8b46c8eb5412683c30c11938b47ad0b51c0f4
7
- data.tar.gz: 955b3fd2b94ffaaf06de061fdd745e98a230ba62464bd0208c41993af70d5646dfb1ff785e3f8a1e39d8fe993bff6601d751626373022fd4a8e75f7fdc2f3f84
6
+ metadata.gz: b4957004998e3f360de92b4724a65a86ea3bc0e8264e5a740c1f8c6d4e725a4e787f449d429cfb2e5e738cd8c60cc81a38f3b481a10682282dc075c22a196ff4
7
+ data.tar.gz: 89b63867df083dccceb9673a9d18b6bfc04dcbe2e592cecf7a24826b753883079e5a8072d4645660a2e2af89427c516eba8019f3f55f189b825f1db9e4f7f3dd
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ GemHadar do
22
22
  dependency 'mize'
23
23
  dependency 'term-ansicolor'
24
24
  dependency 'complex_config'
25
+ dependency 'search_ui'
25
26
 
26
27
  development_dependency 'rake'
27
28
  development_dependency 'simplecov'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.12
1
+ 0.10.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: git-story-workflow 0.9.12 ruby lib
2
+ # stub: git-story-workflow 0.10.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "git-story-workflow".freeze
6
- s.version = "0.9.12"
6
+ s.version = "0.10.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2020-01-15"
11
+ s.date = "2020-02-11"
12
12
  s.description = "Gem abstracting a git workflow\u2026".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["git-story".freeze]
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_runtime_dependency(%q<mize>.freeze, [">= 0"])
36
36
  s.add_runtime_dependency(%q<term-ansicolor>.freeze, [">= 0"])
37
37
  s.add_runtime_dependency(%q<complex_config>.freeze, [">= 0"])
38
+ s.add_runtime_dependency(%q<search_ui>.freeze, [">= 0"])
38
39
  else
39
40
  s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.11.0"])
40
41
  s.add_dependency(%q<rake>.freeze, [">= 0"])
@@ -45,5 +46,6 @@ Gem::Specification.new do |s|
45
46
  s.add_dependency(%q<mize>.freeze, [">= 0"])
46
47
  s.add_dependency(%q<term-ansicolor>.freeze, [">= 0"])
47
48
  s.add_dependency(%q<complex_config>.freeze, [">= 0"])
49
+ s.add_dependency(%q<search_ui>.freeze, [">= 0"])
48
50
  end
49
51
  end
@@ -3,6 +3,8 @@ require 'open-uri'
3
3
  require 'tins/go'
4
4
  require 'set'
5
5
  require 'infobar'
6
+ require 'search_ui'
7
+ require 'amatch'
6
8
 
7
9
  class Git::Story::App
8
10
  class ::String
@@ -13,6 +15,7 @@ class Git::Story::App
13
15
  extend Git::Story::Utils
14
16
  include ComplexConfig::Provider::Shortcuts
15
17
  include Tins::GO
18
+ include SearchUI
16
19
 
17
20
  annotate :command
18
21
 
@@ -315,29 +318,31 @@ class Git::Story::App
315
318
  def switch(pattern = nil)
316
319
  fetch_commits
317
320
  ss = stories.map(&:story_base_name)
318
- if pattern.present?
319
- b = apply_pattern(pattern, ss)
320
- if b.size == 1
321
- b = b.first
322
- else
323
- b = nil
324
- end
325
- end
326
- loop do
327
- unless b
328
- b = complete prompt: 'Story <TAB>? '.bright_blue do |pattern|
329
- apply_pattern(pattern, ss)
330
- end&.strip
331
- b.empty? and return
332
- end
333
- if branch = ss.find { |f| f == b }
334
- sh "git checkout #{branch}"
335
- return "Switched to story: #{branch}".green
336
- else
337
- b = nil
338
- end
321
+ branch = Search.new(
322
+ match: -> answer {
323
+ answer = answer.strip.delete(?#).downcase
324
+
325
+ matcher = Amatch::PairDistance.new(answer)
326
+ matches = ss.map { |n| [ n, -matcher.similar(n.downcase) ] }.
327
+ select { |_, s| s < 0 }.sort_by(&:last).map(&:first)
328
+
329
+ matches.empty? and matches = ss
330
+ matches.first(Tins::Terminal.lines - 1)
331
+ },
332
+ query: -> _answer, matches, selector {
333
+ matches.each_with_index.
334
+ map { |m, i| i == selector ? '⏻ ' + Search.on_blue(m) : '┊ ' + m } * ?\n
335
+ },
336
+ found: -> _answer, matches, selector {
337
+ matches[selector]
338
+ },
339
+ prompt: 'Story? %s'.bold,
340
+ output: STDOUT
341
+ ).start
342
+ if branch
343
+ sh "git checkout #{branch}"
344
+ return "Switched to story: #{branch}".green
339
345
  end
340
- rescue Interrupt
341
346
  end
342
347
 
343
348
  command doc: '[BRANCH] open branch on github'
@@ -1,6 +1,6 @@
1
1
  module Git::Story
2
2
  # Git::Story version
3
- VERSION = '0.9.12'
3
+ VERSION = '0.10.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-story-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: search_ui
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Gem abstracting a git workflow…
140
154
  email: flori@ping.de
141
155
  executables: