git-dd 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git-dd.rb +24 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 119a68302f596f42f45c28c892a860ead6bce8c4
4
- data.tar.gz: 9e31472c5a09d088600e257989893fdb1e896318
3
+ metadata.gz: 562eabc3a7f3fd637d288a411e945901465abccf
4
+ data.tar.gz: 11463fec56a906f9a9f08e6d16ebf86aa743791b
5
5
  SHA512:
6
- metadata.gz: 97938c6dfc866361558d3bfa6455eb469ad3c21819e27d6cff2d791a67a5c2569aa524606c9f291e95087db184ca0c9de8d57031032a8485208063047bc1fbf3
7
- data.tar.gz: 7ad7282cc21c882c32832098cc4d4ae3bfa3e860a694161bb2583b034cf9ddc6ce1751ecfa8729644b5b9dc0a3be0a2afd4a1ee07dbcfa78e91c0e6bb4211f0a
6
+ metadata.gz: c8822502d974cf99b5c5a52ba498740157d0b578b6ed5cf34bf52c3e8a1b017de0b41cc7afbca75a818eb17b784897bb8b2b99d14a606676f887d14006e295eb
7
+ data.tar.gz: 63cfd3aa24afde3ff38cb63ffb7e110bd38b0cbd9a26429072f56c032ff8e1bda8252bc54676c2ac71ba3617d9da38b56236e2112b46ffbe2f6e9383d9aabc9c
data/lib/git-dd.rb CHANGED
@@ -5,16 +5,26 @@ require 'rainbow/ext/string'
5
5
 
6
6
  class GitDD
7
7
  def run
8
- branches = `git branch`
9
- branches = branches.split("\n").select do |b|
10
- b != current_branch_with_mark && !b.include?("* (HEAD detached at")
11
- end
8
+ branch_names = `git branch`
9
+ return if $?.exitstatus != 0
10
+
11
+ branch_names = branch_names.split("\n")
12
+
13
+ branches_with_more_info = `git branch -vv`
14
+ branches_with_more_info = branches_with_more_info.split("\n")
15
+
16
+ return if branch_names.size != branches_with_more_info.size
17
+
18
+ branches = {}
19
+ branch_names.each_with_index { |b, i| branches[b] = branches_with_more_info[i] }
12
20
 
13
- if branches.size == 0
21
+ if branches.size == 1
14
22
  puts "You only have one branch."
15
23
  return
16
24
  end
17
25
 
26
+ branches = branches.select { |k, v| k != current_branch_with_mark && !k.include?("* (HEAD detached at") }
27
+
18
28
  puts "Current branch is: #{current_branch.color(:green)}"
19
29
 
20
30
  prompt = TTY::Prompt.new(interrupt: :exit)
@@ -25,12 +35,18 @@ class GitDD
25
35
  end
26
36
  end
27
37
 
28
- branches_to_delete = prompt.multi_select("Choose branches to delete:", branches, per_page: 20, help: '')
38
+ branches_to_delete = prompt.multi_select("Choose branches to delete:", per_page: 20, help: '',echo: false) do |menu|
39
+ branches.each { |k, v| menu.choice v, k}
40
+ end
41
+
42
+ branches_to_delete.each { |b| puts b.color(:red) }
29
43
 
30
44
  ensure_delete = !prompt.no?('Are you sure?')
31
45
 
32
46
  if ensure_delete
33
- branches_to_delete.each { |b| puts `git branch -D #{b}`}
47
+ branches_to_delete.each do |b|
48
+ puts `git branch -D #{b}`.chomp.color(:yellow)
49
+ end
34
50
  end
35
51
  end
36
52
 
@@ -41,8 +57,6 @@ class GitDD
41
57
  end
42
58
 
43
59
  def current_branch
44
- return @current_branch if @current_branch
45
- @current_branch ||= `git rev-parse --abbrev-ref HEAD`
46
- @current_branch = @current_branch.gsub("\n", '')
60
+ @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
47
61
  end
48
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-dd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weiqing Chu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt