git_left 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2ed757ebc1fe0dd43a521586a07f39f75a7d278
4
+ data.tar.gz: 00be165a1a6fe1f382618125f33e6815a04c8a53
5
+ SHA512:
6
+ metadata.gz: 7c7441e6cfa668114cd08afbbf3d543bbd9e91c89ef6f98a0a3797c3231ce417845e8634843b0247e6395cfd707663b34dd34071681ed0086226316c0c1021d5
7
+ data.tar.gz: 5a328e417fd3955f1d39206992012cdf1383b3cf2eac5678efd21ca96491f05d943605741c6441524cf86bf77670ea83ffea1866386f06218c20e0157cc68d50
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git_left.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chuck Callebs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # git_left
2
+
3
+ git_left aims to help you clean up your lingering git repositories. There are
4
+ better ways I'm sure.
5
+
6
+ The code is straightforward but **use at your own risk**. I didn't write any tests.
7
+
8
+ ## Installation
9
+
10
+ Install it yourself:
11
+
12
+ $ gem install git_left
13
+
14
+ ## Usage
15
+
16
+ ```
17
+ git_left begin
18
+ ```
19
+
20
+ #### Sample session:
21
+
22
+ ```
23
+ ➜ git_left git:(master) ./bin/git_left begin
24
+ Time to clean up your 4 local branches...
25
+
26
+ Deciding time: four-branch (h to delete, l to skip, anything else to quit)
27
+ four-branch deleted
28
+
29
+ Deciding time: one-branch (h to delete, l to skip, anything else to quit)
30
+ one-branch skipped
31
+
32
+ Deciding time: two-branch (h to delete, l to skip, anything else to quit)
33
+ two-branch skipped
34
+
35
+ Deciding time: three-branch (h to delete, l to skip, anything else to quit)
36
+ three-branch skipped
37
+
38
+ You cleaned up all your branches!
39
+ 3 skipped
40
+ 1 deleted
41
+ ```
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ccallebs/git_left.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "git_left"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/git_left ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/git_left'
4
+
5
+ GitLeft::CLI.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/git_left.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_left/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git_left"
8
+ spec.version = GitLeft::VERSION
9
+ spec.authors = ["Chuck Callebs"]
10
+ spec.email = ["chuck@callebs.io"]
11
+
12
+ spec.summary = %q{Swipe left for `git branch` zero.}
13
+ spec.description = %q{Swipe left for `git branch` zero.}
14
+ spec.homepage = "http://github.com/ccallebs/git_left"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = ["git_left"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "thor", "~> 0.19"
23
+ spec.add_dependency "git", "~> 1.3"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.12"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry"
29
+ end
@@ -0,0 +1,39 @@
1
+ module GitLeft
2
+ module Branches
3
+ def self.skipped_branches
4
+ @@skipped_branches || []
5
+ end
6
+
7
+ def self.deleted_branches
8
+ @@deleted_branches || []
9
+ end
10
+
11
+ def self.skip(branch)
12
+ @@skipped_branches ||= []
13
+ @@skipped_branches << branch.name
14
+ end
15
+
16
+ def self.delete(branch)
17
+ @@deleted_branches ||= []
18
+ @@deleted_branches << branch.name
19
+
20
+ branch.delete
21
+ end
22
+
23
+ def self.branches_to_omit
24
+ @@skipped_branches + @@deleted_branches + ['master']
25
+ end
26
+
27
+ def self.random_branch
28
+ branches.sample
29
+ end
30
+
31
+ def self.branches
32
+ @@skipped_branches ||= []
33
+ @@deleted_branches ||= []
34
+
35
+ @@all_branches = Git.open('.').branches.to_a
36
+ @@all_branches.select { |b| !branches_to_omit.include?(b.name) }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require "thor"
2
+ require "git"
3
+
4
+ module GitLeft
5
+ class CLI < Thor
6
+ desc "begin", "Begin swiping left"
7
+ def begin(opts = {})
8
+ puts "Time to clean up your #{GitLeft::Branches.branches.count} local branches..."
9
+
10
+ while(1) do
11
+ random_branch = GitLeft::Branches.random_branch
12
+
13
+ if random_branch.nil?
14
+ puts "\nYou cleaned up all your branches!"
15
+ puts "\t#{GitLeft::Branches.skipped_branches.count} skipped"
16
+ puts "\t#{GitLeft::Branches.deleted_branches.count} deleted"
17
+ break
18
+ end
19
+
20
+ underlined = "\e[4m" << random_branch.name << "\e[24m"
21
+ puts "\nDeciding time: #{underlined} (h to delete, l to skip, anything else to quit)\n"
22
+
23
+ case GitLeft::KeyParser.new(STDIN.getch).action
24
+ when :delete
25
+ GitLeft::Branches.delete(random_branch)
26
+ puts "#{random_branch.name} deleted"
27
+ next
28
+ when :skip
29
+ GitLeft::Branches.skip(random_branch)
30
+ puts "#{random_branch.name} skipped"
31
+ next
32
+ when :quit
33
+ puts "See ya!"
34
+ break
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ module GitLeft
2
+ class KeyParser
3
+ def initialize(input)
4
+ @input = input
5
+ end
6
+
7
+ def action
8
+ case @input
9
+ when "h"
10
+ :delete
11
+ when "l"
12
+ :skip
13
+ else
14
+ :quit
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module GitLeft
2
+ VERSION = "0.1.2"
3
+ end
data/lib/git_left.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "git_left/version"
2
+ require "git_left/branches"
3
+ require "git_left/key_parser"
4
+ require "git_left/cli"
5
+
6
+ module GitLeft
7
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_left
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Chuck Callebs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Swipe left for `git branch` zero.
98
+ email:
99
+ - chuck@callebs.io
100
+ executables:
101
+ - git_left
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/git_left
114
+ - bin/setup
115
+ - git_left.gemspec
116
+ - lib/git_left.rb
117
+ - lib/git_left/branches.rb
118
+ - lib/git_left/cli.rb
119
+ - lib/git_left/key_parser.rb
120
+ - lib/git_left/version.rb
121
+ homepage: http://github.com/ccallebs/git_left
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.5.1
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Swipe left for `git branch` zero.
145
+ test_files: []