git-story-workflow 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a262c355dd2d101911c442e5e9ba5d12da74967e3db37a600dc5f2f21ed1d9
4
- data.tar.gz: bfe8ea9f227c933eaec80aae69bef429cac5d76eb311b0ddf40b7bd6247e7779
3
+ metadata.gz: c437719bf4e7298ee339477a48e37e6652a028876c7c1ef524953a24792b4099
4
+ data.tar.gz: 2dfe54728f5d8ad1d0655ad6e9c1706e905ae952af8678812002bb2fc6b20f46
5
5
  SHA512:
6
- metadata.gz: b4957004998e3f360de92b4724a65a86ea3bc0e8264e5a740c1f8c6d4e725a4e787f449d429cfb2e5e738cd8c60cc81a38f3b481a10682282dc075c22a196ff4
7
- data.tar.gz: 89b63867df083dccceb9673a9d18b6bfc04dcbe2e592cecf7a24826b753883079e5a8072d4645660a2e2af89427c516eba8019f3f55f189b825f1db9e4f7f3dd
6
+ metadata.gz: d32bb92036c60fbea1492caa8c79fc211d96aa60adc389386d9e8ed585d3613c8a3abf8562c19fafdf68450a6a21a3b4ff297a0df94ac111ff7a5317aa3b1942
7
+ data.tar.gz: 571614a5c236d81ea10bbe3628ff5bbf2812d6d1b2f68b479fcb2c0d02c6b2c55d54cbb367e3b3bf49592c8ef4e5b03cbc58f8098df6e7f276d018716135b85c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: git-story-workflow 0.10.0 ruby lib
2
+ # stub: git-story-workflow 0.11.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "git-story-workflow".freeze
6
- s.version = "0.10.0"
6
+ s.version = "0.11.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-02-11"
11
+ s.date = "2020-02-28"
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]
data/lib/git/story/app.rb CHANGED
@@ -317,34 +317,25 @@ class Git::Story::App
317
317
  command doc: '[PATTERN] switch to story matching PATTERN'
318
318
  def switch(pattern = nil)
319
319
  fetch_commits
320
- ss = stories.map(&:story_base_name)
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
320
+ if branch = pick_branch(prompt: 'Switch to story? %s')
343
321
  sh "git checkout #{branch}"
344
322
  return "Switched to story: #{branch}".green
345
323
  end
346
324
  end
347
325
 
326
+ command doc: '[PATTERN] delete story branch matching PATTERN'
327
+ def delete(pattern = nil)
328
+ fetch_commits
329
+ if branch = pick_branch(prompt: 'Delete story branch? %s', symbol: ?⌦)
330
+ sh "git pull origin #{branch}"
331
+ sh "git branch -d #{branch}"
332
+ if ask(prompt: 'Delete remote branch? (y/N) ') =~ /\Ay\z/i
333
+ sh "git push origin #{branch} --delete"
334
+ end
335
+ return "Deleted story branch: #{branch}".green
336
+ end
337
+ end
338
+
348
339
  command doc: '[BRANCH] open branch on github'
349
340
  def github(branch = current(check: false))
350
341
  if url = github_url(branch)
@@ -364,6 +355,31 @@ class Git::Story::App
364
355
 
365
356
  private
366
357
 
358
+ def pick_branch(prompt:, symbol: ?⏻)
359
+ ss = stories.map(&:story_base_name)
360
+ branch = Search.new(
361
+ match: -> answer {
362
+ answer = answer.strip.delete(?#).downcase
363
+
364
+ matcher = Amatch::PairDistance.new(answer)
365
+ matches = ss.map { |n| [ n, -matcher.similar(n.downcase) ] }.
366
+ select { |_, s| s < 0 }.sort_by(&:last).map(&:first)
367
+
368
+ matches.empty? and matches = ss
369
+ matches.first(Tins::Terminal.lines - 1)
370
+ },
371
+ query: -> _answer, matches, selector {
372
+ matches.each_with_index.
373
+ map { |m, i| i == selector ? "#{symbol} " + Search.on_blue(m) : '┊ ' + m } * ?\n
374
+ },
375
+ found: -> _answer, matches, selector {
376
+ matches[selector]
377
+ },
378
+ prompt: prompt.bold,
379
+ output: STDOUT
380
+ ).start
381
+ end
382
+
367
383
  def default_ref
368
384
  tags.last
369
385
  end
@@ -1,6 +1,6 @@
1
1
  module Git::Story
2
2
  # Git::Story version
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.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.10.0
4
+ version: 0.11.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-02-11 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar