git_left 0.1.3 → 0.1.4
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/lib/git_left/branch.rb +21 -0
- data/lib/git_left/branch_reporter.rb +34 -0
- data/lib/git_left/branches.rb +10 -2
- data/lib/git_left/cli.rb +9 -5
- data/lib/git_left/version.rb +1 -1
- data/lib/git_left.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2760c0ff60fc7835d8f6fe11af1121a9b87b5dce
|
4
|
+
data.tar.gz: fdfb54e749546fc4b36a02d2dac64a330ed1c8e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f344ff90fdb42821e67157c357bda9d9a5a1a70170dd010b2b72370e820ecf06f89bb28e231dae9fa3c42290b316226ddc8063e5b2087c93cd43b6e7a4eb33d0
|
7
|
+
data.tar.gz: a3ebc0a2c332e28dc3996213358063afde5647247aca4e711dab1632a9cc3ae7e9f130a5af7904b1c3bde2b00106860fe64f33d6c838f29d28a5e6d40799ad47
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GitLeft
|
2
|
+
class Branch
|
3
|
+
def initialize(branch)
|
4
|
+
@branch = branch
|
5
|
+
end
|
6
|
+
|
7
|
+
def is_upstream?
|
8
|
+
GitLeft::Branches.remote_branches.map(&:name).include?(@branch.name)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Delegated Methods
|
12
|
+
|
13
|
+
def name
|
14
|
+
@branch.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete
|
18
|
+
@branch.delete
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module GitLeft
|
2
|
+
class BranchReporter
|
3
|
+
def initialize(branch)
|
4
|
+
@branch = branch
|
5
|
+
end
|
6
|
+
|
7
|
+
def report
|
8
|
+
puts branch_info
|
9
|
+
puts instructions
|
10
|
+
end
|
11
|
+
|
12
|
+
def branch_info
|
13
|
+
str = "\nDeciding time: #{underlined(@branch.name)}"
|
14
|
+
|
15
|
+
if @branch.is_upstream?
|
16
|
+
str << green(" (exists upstream)")
|
17
|
+
end
|
18
|
+
|
19
|
+
str
|
20
|
+
end
|
21
|
+
|
22
|
+
def instructions
|
23
|
+
"(h to delete, l to skip, anything else to quit)\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def underlined(text)
|
27
|
+
"\e[4m" << text << "\e[24m"
|
28
|
+
end
|
29
|
+
|
30
|
+
def green(text)
|
31
|
+
"\e[32m#{text}\e[0m"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/git_left/branches.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module GitLeft
|
2
2
|
module Branches
|
3
|
+
def self.git_instance
|
4
|
+
@git_instance ||= Git.open('.')
|
5
|
+
end
|
6
|
+
|
3
7
|
def self.skipped_branches
|
4
8
|
@@skipped_branches || []
|
5
9
|
end
|
@@ -28,12 +32,16 @@ module GitLeft
|
|
28
32
|
branches.sample
|
29
33
|
end
|
30
34
|
|
35
|
+
def self.remote_branches
|
36
|
+
@remote_branches ||= git_instance.branches.remote
|
37
|
+
end
|
38
|
+
|
31
39
|
def self.branches
|
32
40
|
@@skipped_branches ||= []
|
33
41
|
@@deleted_branches ||= []
|
34
42
|
|
35
|
-
@@all_branches ||=
|
36
|
-
@@all_branches.select { |b| !branches_to_omit.include?(b.name)
|
43
|
+
@@all_branches ||= git_instance.branches.local.to_a.map { |b| GitLeft::Branch.new(b) }
|
44
|
+
@@all_branches.select { |b| !branches_to_omit.include?(b.name) }
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
data/lib/git_left/cli.rb
CHANGED
@@ -5,7 +5,13 @@ module GitLeft
|
|
5
5
|
class CLI < Thor
|
6
6
|
desc "begin", "Begin swiping left"
|
7
7
|
def begin(opts = {})
|
8
|
-
puts "
|
8
|
+
puts "Before we begin, prune remote branches? (y/n)"
|
9
|
+
if STDIN.getch == 'y'
|
10
|
+
puts "Pruning remote branches..."
|
11
|
+
`git remote prune origin`
|
12
|
+
end
|
13
|
+
|
14
|
+
puts "Okay, time to clean up your #{GitLeft::Branches.branches.count} local branches..."
|
9
15
|
|
10
16
|
while(1) do
|
11
17
|
begin
|
@@ -13,13 +19,11 @@ module GitLeft
|
|
13
19
|
|
14
20
|
if @random_branch.nil?
|
15
21
|
puts "\nYou cleaned up all your branches!"
|
16
|
-
puts "\t#{GitLeft::Branches.skipped_branches.count} skipped"
|
17
|
-
puts "\t#{GitLeft::Branches.deleted_branches.count} deleted"
|
18
22
|
break
|
19
23
|
end
|
20
24
|
|
21
|
-
|
22
|
-
|
25
|
+
@reporter = GitLeft::BranchReporter.new(@random_branch)
|
26
|
+
@reporter.report
|
23
27
|
|
24
28
|
case GitLeft::KeyParser.new(STDIN.getch).action
|
25
29
|
when :delete
|
data/lib/git_left/version.rb
CHANGED
data/lib/git_left.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_left
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuck Callebs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -114,6 +114,8 @@ files:
|
|
114
114
|
- bin/setup
|
115
115
|
- git_left.gemspec
|
116
116
|
- lib/git_left.rb
|
117
|
+
- lib/git_left/branch.rb
|
118
|
+
- lib/git_left/branch_reporter.rb
|
117
119
|
- lib/git_left/branches.rb
|
118
120
|
- lib/git_left/cli.rb
|
119
121
|
- lib/git_left/key_parser.rb
|