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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70e1da0581b561e432b0676c50e4fe84ccc681e0
4
- data.tar.gz: 6a5e54ab4e3d39c3345db03d53ca578334662141
3
+ metadata.gz: 2760c0ff60fc7835d8f6fe11af1121a9b87b5dce
4
+ data.tar.gz: fdfb54e749546fc4b36a02d2dac64a330ed1c8e9
5
5
  SHA512:
6
- metadata.gz: abda837f7ea2d42bf79dde62b731a5f30817e3c42bd77d2be87a7202d6fd07a84dbfb8fb5f3c75d41cfbe8b8ecc2c38c078f6db2f4a507db5dcbd0817a405eb7
7
- data.tar.gz: 255be76e956cfe0120cd8baeed77d6a2dd74c3c00c1f77546039d2c26ff7469eec7ef961242c18cfb1358bd6e2366b4a96e1f051279411041c10b7d9a104fc12
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
@@ -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 ||= Git.open('.').branches.to_a
36
- @@all_branches.select { |b| !branches_to_omit.include?(b.name) && !b.remote }
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 "Time to clean up your #{GitLeft::Branches.branches.count} local branches..."
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
- underlined = "\e[4m" << @random_branch.name << "\e[24m"
22
- puts "\nDeciding time: #{underlined} (h to delete, l to skip, anything else to quit)\n"
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
@@ -1,3 +1,3 @@
1
1
  module GitLeft
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/git_left.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require_relative "git_left/version"
2
+ require_relative "git_left/branch"
3
+ require_relative "git_left/branch_reporter"
2
4
  require_relative "git_left/branches"
3
5
  require_relative "git_left/key_parser"
4
6
  require_relative "git_left/cli"
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.3
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-26 00:00:00.000000000 Z
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