reflog-review 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcb3e90783038bcc935bafa506306a7d20af8e2c
4
+ data.tar.gz: 791af717950ea642c3810929bb802d3483374719
5
+ SHA512:
6
+ metadata.gz: ddb4b9b9c840a24effad09c64026802a36fa8282a437dfbe1f168fe852b6c2fa76c6824484c792941f2f167da114102722aecd07fb471e135b12275ceab55618
7
+ data.tar.gz: ab20c3c4f940e3742b23f676a1ec95aaa7f5fb7250bb57235e853a179f41c76d9d0873fcc7711f232ad9b27f746634dde085039ab3743498d3d9d02d594abbad
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'colorize'
4
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ coderay (1.1.0)
5
+ colorize (0.7.3)
6
+ method_source (0.8.2)
7
+ pry (0.10.1)
8
+ coderay (~> 1.1.0)
9
+ method_source (~> 0.8.1)
10
+ slop (~> 3.4)
11
+ slop (3.6.0)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ colorize
18
+ pry
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Blaine Schmeisser
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/bin/reflog-review ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/reflog_review'
4
+ ReflogReview.new.iterate
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/reflog_review'
4
+ ReflogReview.new.iterate
data/lib/reflog.rb ADDED
@@ -0,0 +1,23 @@
1
+ class Reflog
2
+
3
+ def initialize
4
+ @pointer = 0
5
+ end
6
+
7
+ def next
8
+ @pointer += 1
9
+ end
10
+
11
+ def prev
12
+ @pointer -= 1 if @pointer > 0
13
+ end
14
+
15
+ def show
16
+ `git show HEAD@{#{@pointer}}`
17
+ end
18
+
19
+ def pick
20
+ `git reset --hard HEAD@{#{@pointer}}`
21
+ end
22
+
23
+ end
@@ -0,0 +1,78 @@
1
+ require 'colorize'
2
+ require_relative 'reflog'
3
+
4
+ class ReflogReview
5
+
6
+ attr_accessor :log
7
+
8
+ def initialize
9
+ @log = Reflog.new
10
+ end
11
+
12
+ def command_?
13
+ puts [
14
+ "j - next commit",
15
+ "k - previous commit",
16
+ "p - pick commit",
17
+ "s - show current head",
18
+ "? - print help",
19
+ ].join("\n").colorize(:light_red)
20
+ end
21
+
22
+ def command_j
23
+ log.next and show_head
24
+ end
25
+
26
+ def command_k
27
+ log.prev and show_head
28
+ end
29
+
30
+ def command_s
31
+ show_head
32
+ end
33
+
34
+ def command_q
35
+ puts "\n\nYou just lost the game.".colorize(:black)
36
+ exit
37
+ end
38
+
39
+ def command_p
40
+ log.pick and command_q
41
+ end
42
+
43
+ def method_missing(method, *args)
44
+ puts "Invalid input."
45
+ command_?
46
+ end
47
+
48
+ def prompt!
49
+ status = "Is this the drone you are looking for [j,k,p,q,?]? "
50
+ print status.colorize(:light_blue)
51
+ end
52
+
53
+ def show_head
54
+ log.show.split("\n").each do |line|
55
+ if line.match /^\+/
56
+ puts line.colorize(:green)
57
+ elsif line.match /^\-/
58
+ puts line.colorize(:red)
59
+ elsif new_line = line.match(/commit [a-f0-9]{40}$/)
60
+ puts new_line.to_s.colorize(:yellow)
61
+ elsif line.match /^@@/
62
+ print line.split('@@ ')[0] + '@@ '.colorize(:light_blue)
63
+ puts line.split('@@ ')[1]
64
+ else
65
+ puts line
66
+ end
67
+ end
68
+ end
69
+
70
+ def iterate
71
+ show_head
72
+ loop do
73
+ prompt!
74
+ send("command_#{gets.chomp.to_sym}")
75
+ end
76
+ end
77
+
78
+ end
data/readme.md ADDED
@@ -0,0 +1,29 @@
1
+ The reflog doesn't have to scare you.
2
+
3
+ If you lost your place just run `git review` and this will iterate you through your reflog, showing you the diff, until you find the commit you want.
4
+
5
+ ## Usage
6
+ ~~~ bash
7
+ git review
8
+ ~~~
9
+
10
+ ### Commands
11
+ ~~~
12
+ j - next commit
13
+ k - previous commit
14
+ p - pick commit
15
+ s - show current head
16
+ ? - print help
17
+ ~~~
18
+
19
+ ## Install
20
+ ~~~ bash
21
+ git clone git@github.com:blainesch/reflog-review.git ~/reflog-review
22
+ cd ~/reflog-review && bundle install
23
+ ~~~
24
+
25
+ Add this to your `.gitconfig` file.
26
+ ~~~ prolog
27
+ [alias]
28
+ review = !sh -c 'ruby ~/reflog-review/bin/reflog-review.rb'
29
+ ~~~
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.authors = 'Blaine Schmeisser'
3
+ s.name = 'reflog-review'
4
+ s.email = 'blainesch@gmail.com'
5
+ s.homepage = 'https://github.com/blainesch/reflog-review'
6
+ s.version = '0.0.2'
7
+ s.summary = 'Easily review your reflog and recover commits.'
8
+ s.description = 'You never lose a commit in GIT, but sometimes it is harder then it should be to recover it. This tool allows you easily review commits in the reflog one at a time.'
9
+ s.licenses = ['MIT']
10
+ s.require_paths = ['lib', 'bin']
11
+ s.files = `git ls-files`.split("\n")
12
+ s.has_rdoc = false
13
+ s.executables << 'reflog-review'
14
+ s.add_dependency 'colorize'
15
+ s.add_development_dependency 'pry'
16
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reflog-review
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Blaine Schmeisser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: You never lose a commit in GIT, but sometimes it is harder then it should
42
+ be to recover it. This tool allows you easily review commits in the reflog one at
43
+ a time.
44
+ email: blainesch@gmail.com
45
+ executables:
46
+ - reflog-review
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - bin/reflog-review
54
+ - bin/reflog-review.rb
55
+ - lib/reflog.rb
56
+ - lib/reflog_review.rb
57
+ - readme.md
58
+ - reflow-review.gemspec
59
+ homepage: https://github.com/blainesch/reflog-review
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ - bin
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.5
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Easily review your reflog and recover commits.
84
+ test_files: []