herodot 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/herodot/commands.rb +14 -6
- data/lib/herodot/configuration.rb +1 -1
- data/lib/herodot/parser.rb +1 -1
- data/lib/herodot/version.rb +1 -1
- data/lib/herodot.rb +19 -4
- metadata +3 -4
- data/post-checkout +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c56f76d186ec1df50f95f5883ed9dddbc783a2b
|
4
|
+
data.tar.gz: 5c4a6ee9098fcdbaba1f5c9177e3097323cacbfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32b26214e6083a539be512c1de6873da6b487c2442b37b0a03d08a99972e89f4b2e6039a28dd983c3b77af25b6dccc4fa76a47dc2fd8442510e15d378054abb3
|
7
|
+
data.tar.gz: bff391404a04784f6b839d8881cee04f288c600c604290009dd3edf1513b690ad486efcb7fea4ba0c6844279cc42a31e6aea051d1d7b5b43a30cdfc436a35fa9
|
data/lib/herodot/commands.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
+
require 'date'
|
1
2
|
require 'chronic'
|
2
3
|
require 'fileutils'
|
3
4
|
|
4
5
|
class Herodot::Commands
|
5
|
-
SCRIPT = "#!/bin/
|
6
|
-
|
7
|
-
"project=$(pwd)\n"\
|
8
|
-
"branch=$(git rev-parse --abbrev-ref HEAD)\n"\
|
9
|
-
'echo "$(date);$project;$branch" >> ~/worklog'.freeze
|
6
|
+
SCRIPT = "#!/bin/sh\nherodot track $(pwd)".freeze
|
7
|
+
|
10
8
|
DEFAULT_RANGE = 'this week'.freeze
|
11
9
|
|
12
10
|
def self.show(args, config, opts = {})
|
@@ -19,7 +17,7 @@ class Herodot::Commands
|
|
19
17
|
puts output
|
20
18
|
end
|
21
19
|
|
22
|
-
def self.
|
20
|
+
def self.init(path, config)
|
23
21
|
path = '.' if path.nil?
|
24
22
|
puts "Start tracking of `#{File.expand_path(path)}` into `#{config.worklog_file}`."
|
25
23
|
hooks = "#{path}/.git/hooks"
|
@@ -31,6 +29,16 @@ class Herodot::Commands
|
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
32
|
+
def self.track(path, config)
|
33
|
+
puts 'Logging into worklog'
|
34
|
+
File.open(config.worklog_file, 'a') do |worklog|
|
35
|
+
datestr = DateTime.now.strftime("%a %b %e %H:%M:%S %z %Y")
|
36
|
+
branch = `(cd #{path} && git rev-parse --abbrev-ref HEAD)`.strip
|
37
|
+
line = [datestr, path, branch].join(";")
|
38
|
+
worklog.puts(line)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
def self.link(path)
|
35
43
|
path = '.' if path.nil?
|
36
44
|
choose do |menu|
|
data/lib/herodot/parser.rb
CHANGED
@@ -2,7 +2,7 @@ require 'csv'
|
|
2
2
|
|
3
3
|
class Herodot::Parser
|
4
4
|
NO_SUCH_FILE = Rainbow('Worklog missing.').red +
|
5
|
-
' Use `herodot
|
5
|
+
' Use `herodot init` to start tracking a git repository'\
|
6
6
|
' or `herodot help` to open the man page.'.freeze
|
7
7
|
class << self
|
8
8
|
def parse(range, config)
|
data/lib/herodot/version.rb
CHANGED
data/lib/herodot.rb
CHANGED
@@ -18,6 +18,7 @@ class Herodot::Application
|
|
18
18
|
program :description, 'Tracks your work based on git branch checkouts'
|
19
19
|
|
20
20
|
config = Herodot::Configuration.new
|
21
|
+
init_command(config)
|
21
22
|
track_command(config)
|
22
23
|
show_command(config)
|
23
24
|
link_command(config)
|
@@ -25,14 +26,28 @@ class Herodot::Application
|
|
25
26
|
run!
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
INIT_DESCRIPTION = 'This command sets up post commit and post checkout hooks'\
|
29
30
|
', that will log the current branch into the worklog file.'.freeze
|
31
|
+
def init_command(config)
|
32
|
+
command :init do |c|
|
33
|
+
c.syntax = 'herodot init [<repository path>]'
|
34
|
+
c.summary = 'Start tracking a repository'
|
35
|
+
c.description = INIT_DESCRIPTION
|
36
|
+
c.example 'Start tracking current repository', 'herodot init'
|
37
|
+
c.action do |args, _|
|
38
|
+
Herodot::Commands.init(args[0], config)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
TRACK_DESCRIPTION = 'This command tracks the current branch/commit in a repo '\
|
44
|
+
'and is called from the git hooks installed via `herodot init`.'.freeze
|
30
45
|
def track_command(config)
|
31
46
|
command :track do |c|
|
32
|
-
c.syntax = 'herodot track
|
33
|
-
c.summary = '
|
47
|
+
c.syntax = 'herodot track <repository path>'
|
48
|
+
c.summary = 'Record git activity in a repository (used internally)'
|
34
49
|
c.description = TRACK_DESCRIPTION
|
35
|
-
c.example '
|
50
|
+
c.example 'Record the latest branch name etc. to the worklog', 'herodot track .'
|
36
51
|
c.action do |args, _|
|
37
52
|
Herodot::Commands.track(args[0], config)
|
38
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herodot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bitcrowd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -180,7 +180,6 @@ files:
|
|
180
180
|
- lib/herodot/project_link.rb
|
181
181
|
- lib/herodot/version.rb
|
182
182
|
- lib/herodot/worklog.rb
|
183
|
-
- post-checkout
|
184
183
|
homepage: https://github.com/bitcrowd/herodot
|
185
184
|
licenses:
|
186
185
|
- MIT
|
@@ -201,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
200
|
version: '0'
|
202
201
|
requirements: []
|
203
202
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.5.2
|
205
204
|
signing_key:
|
206
205
|
specification_version: 4
|
207
206
|
summary: Track your work with your git activity.
|