git-dd 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/git-dd +5 -0
  3. data/lib/git-dd.rb +48 -0
  4. metadata +74 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 119a68302f596f42f45c28c892a860ead6bce8c4
4
+ data.tar.gz: 9e31472c5a09d088600e257989893fdb1e896318
5
+ SHA512:
6
+ metadata.gz: 97938c6dfc866361558d3bfa6455eb469ad3c21819e27d6cff2d791a67a5c2569aa524606c9f291e95087db184ca0c9de8d57031032a8485208063047bc1fbf3
7
+ data.tar.gz: 7ad7282cc21c882c32832098cc4d4ae3bfa3e860a694161bb2583b034cf9ddc6ce1751ecfa8729644b5b9dc0a3be0a2afd4a1ee07dbcfa78e91c0e6bb4211f0a
data/bin/git-dd ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'git-dd'
4
+
5
+ GitDD.new.run
data/lib/git-dd.rb ADDED
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ require 'tty-prompt'
4
+ require 'rainbow/ext/string'
5
+
6
+ class GitDD
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
12
+
13
+ if branches.size == 0
14
+ puts "You only have one branch."
15
+ return
16
+ end
17
+
18
+ puts "Current branch is: #{current_branch.color(:green)}"
19
+
20
+ prompt = TTY::Prompt.new(interrupt: :exit)
21
+
22
+ prompt.on(:keypress) do |event|
23
+ if event.value == 'q'
24
+ return
25
+ end
26
+ end
27
+
28
+ branches_to_delete = prompt.multi_select("Choose branches to delete:", branches, per_page: 20, help: '')
29
+
30
+ ensure_delete = !prompt.no?('Are you sure?')
31
+
32
+ if ensure_delete
33
+ branches_to_delete.each { |b| puts `git branch -D #{b}`}
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def current_branch_with_mark
40
+ @current_branch_with_mark ||= "* #{current_branch}"
41
+ end
42
+
43
+ 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", '')
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-dd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Weiqing Chu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-prompt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: cwq1913@gmail.com
43
+ executables:
44
+ - git-dd
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/git-dd
49
+ - lib/git-dd.rb
50
+ homepage: https://github.com/Sanster/git-dd
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.6.10
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: git command to delete branches interactively
74
+ test_files: []