checkout 0.0.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.
- checksums.yaml +7 -0
- data/bin/checkout +4 -0
- data/lib/checkout.rb +6 -0
- data/lib/checkout/runner.rb +71 -0
- data/lib/checkout/version.rb +3 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c75d1c6f22af03e13951212b14d071f6c366adb321d9241e5a51eca72b1b246
|
4
|
+
data.tar.gz: b00253ff8e61ae442a82fb0341e6d3c34ad6ea47020d2069a8c62bb010ba3b0e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02ae34a3a0f35bbb7c8352dd089af08a59681a9252e6d783f070187ca4f39674d62587ff9186c6013ffda82cb7bfc4b21f55221018786de6018d287fff922940
|
7
|
+
data.tar.gz: 26c4e6b4f5de190b56bf92686724aca28694f90d3b03b3dc452415bd3c473bcdf7e425e21f3ec1419ab41a0628f6765bb1457cc53366e2560f23f95aa06e2e8d
|
data/bin/checkout
ADDED
data/lib/checkout.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
module Checkout
|
4
|
+
class Runner
|
5
|
+
attr_accessor :max, :branches, :branch_choice_object, :selection, :branch
|
6
|
+
|
7
|
+
def initialize(max)
|
8
|
+
if max.nil?
|
9
|
+
puts "max is 10"
|
10
|
+
@max ||= 10
|
11
|
+
else
|
12
|
+
puts "max is #{max}"
|
13
|
+
@max ||= max.to_i
|
14
|
+
end
|
15
|
+
run!
|
16
|
+
end
|
17
|
+
|
18
|
+
def run!
|
19
|
+
puts "asking"
|
20
|
+
ask_for_selection
|
21
|
+
puts 'mapping selection'
|
22
|
+
map_selection_to_branch
|
23
|
+
puts 'checking out'
|
24
|
+
checkout
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def ask_for_selection
|
30
|
+
puts 'Choose a branch...'
|
31
|
+
puts ''
|
32
|
+
display_branches
|
33
|
+
@selection ||= STDIN.gets.chomp
|
34
|
+
end
|
35
|
+
|
36
|
+
def map_selection_to_branch
|
37
|
+
puts "selection is #{selection}"
|
38
|
+
@branch ||= branch_choice_object[selection.to_i]
|
39
|
+
puts "branch is #{@branch}"
|
40
|
+
puts "branch choice object is #{branch_choice_object}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def branches
|
44
|
+
@branches ||= `git for-each-ref --sort=-committerdate refs/heads/`
|
45
|
+
.split(/\n/)
|
46
|
+
.map { |b| b.match(/heads\//).post_match }
|
47
|
+
end
|
48
|
+
|
49
|
+
def branch_choice_object
|
50
|
+
limit = (max > branches.size) ? branches.size : max
|
51
|
+
@branch_choice_object ||= Hash[(0...limit).zip(branches)]
|
52
|
+
end
|
53
|
+
|
54
|
+
def display_branches
|
55
|
+
branch_choice_object.each do |k, v|
|
56
|
+
puts "k is #{k}"
|
57
|
+
puts "v is #{v}"
|
58
|
+
puts "k dot size is #{k.to_s.size}"
|
59
|
+
puts "branch is #{branch}"
|
60
|
+
dashes = "-" * (5 - k.to_s.size)
|
61
|
+
puts "#{k.to_s.colorize(:yellow)} #{dashes} #{v.colorize(:green)}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def checkout
|
66
|
+
puts "Now checking out #{branch}"
|
67
|
+
`git checkout #{branch}`
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: checkout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Lerner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: cheeseandpepper@gmail.com
|
15
|
+
executables:
|
16
|
+
- checkout
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/checkout
|
21
|
+
- lib/checkout.rb
|
22
|
+
- lib/checkout/runner.rb
|
23
|
+
- lib/checkout/version.rb
|
24
|
+
homepage:
|
25
|
+
licenses: []
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.7.6
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: checkout lets you switch branches easily
|
47
|
+
test_files: []
|