omglog 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.
- data/bin/omglog +51 -0
- metadata +47 -0
data/bin/omglog
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
require 'rb-fsevent'
|
4
|
+
|
5
|
+
CLEAR = "\n----\n"
|
6
|
+
YELLOW, BLUE, GREY, HIGHLIGHT = '0;33', '0;34', '0;90', '1;30;47'
|
7
|
+
SHORTEST_MESSAGE = 12
|
8
|
+
LOG_CMD = %{git log --all --date-order --graph --color --pretty="format: \2%h\3\2%d\3\2 %an, %ar\3\2 %s\3"}
|
9
|
+
LOG_REGEX = /(.*)\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003/
|
10
|
+
|
11
|
+
def omglog
|
12
|
+
rows, cols = `tput lines; tput cols`.scan(/\d+/).map(&:to_i)
|
13
|
+
`#{LOG_CMD} -#{rows}`.tap {|log|
|
14
|
+
print CLEAR + log.split("\n")[0...(rows - 1)].map {|l|
|
15
|
+
commit = l.scan(LOG_REGEX).flatten.map(&:to_s)
|
16
|
+
commit.any? ? render_commit(commit, cols) : l
|
17
|
+
}.join("\n") + "\n" + "\e[#{GREY}mupdated #{Time.now.strftime("%a %H:%M:%S")}\e[m ".rjust(cols + 8)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def render_commit commit, cols
|
22
|
+
row_highlight = commit[2][/[^\/]HEAD\b/] ? HIGHLIGHT : YELLOW
|
23
|
+
[nil, row_highlight, BLUE, '', GREY].map {|c| "\e[#{c}m" if c }.zip(
|
24
|
+
arrange_commit(commit, cols)
|
25
|
+
).join + "\e[m"
|
26
|
+
end
|
27
|
+
|
28
|
+
def arrange_commit commit, cols
|
29
|
+
commit[0].chomp!(' ')
|
30
|
+
commit[-2].sub!(/(\d+)\s(\w)[^\s]+ ago/, '\1\2 ago')
|
31
|
+
room = [cols - [commit[0].gsub(/\e\[[\d;]*m/, ''), commit[1..-2]].flatten.map(&:length).inject(&:+), SHORTEST_MESSAGE].max
|
32
|
+
commit.tap {|commit|
|
33
|
+
commit[3, 0] = if commit[-1].length > room
|
34
|
+
commit.pop[0...(room - 1)] + '…'
|
35
|
+
else
|
36
|
+
commit.pop.ljust(room)
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_change &block
|
42
|
+
FSEvent.new.tap {|fsevent|
|
43
|
+
fsevent.watch('.git', &block)
|
44
|
+
fsevent.run
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
abort("Run omglog at the root of the git repo you'd like to watch.") if (ARGV & %w[-h --help help]).any?
|
49
|
+
abort("The current directory doesn't look like the root of a git repo.") unless File.directory?('.git')
|
50
|
+
omglog
|
51
|
+
on_change { omglog }
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omglog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Hoskings
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Realtime git logging using fseventsd. omg!
|
15
|
+
email: ben@hoskings.net
|
16
|
+
executables:
|
17
|
+
- omglog
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/omglog
|
22
|
+
homepage: http://github.com/benhoskings/omglog
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Realtime git logging using fseventsd.
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|