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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 889ec3c6c65c2052c4171a48b30b2768094defc6
4
- data.tar.gz: fce17954a730070afbd210ba3fd6838edacb520b
3
+ metadata.gz: 6c56f76d186ec1df50f95f5883ed9dddbc783a2b
4
+ data.tar.gz: 5c4a6ee9098fcdbaba1f5c9177e3097323cacbfd
5
5
  SHA512:
6
- metadata.gz: 885dfbdfe82891872825f646e3c3ef6267d90fd8b07d31876afc73f3b5f2a18b0a0c2001686cb86150e934d8c476194b1da42179e62c89c80c53399ac8eaa0c3
7
- data.tar.gz: 8cbb20433cc8af7f2fa1361ebb8b05d373fd17cb5a60f6d8a95e59eb87f5453d32e7f4113a2fcbc4c6fd8f6bf78957c2d184a8bf8764bcdc2f4c2402f6b5c02f
6
+ metadata.gz: 32b26214e6083a539be512c1de6873da6b487c2442b37b0a03d08a99972e89f4b2e6039a28dd983c3b77af25b6dccc4fa76a47dc2fd8442510e15d378054abb3
7
+ data.tar.gz: bff391404a04784f6b839d8881cee04f288c600c604290009dd3edf1513b690ad486efcb7fea4ba0c6844279cc42a31e6aea051d1d7b5b43a30cdfc436a35fa9
@@ -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/bash\n"\
6
- "echo 'Logging into worklog'\n"\
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.track(path, config)
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|
@@ -12,7 +12,7 @@ class Herodot::Configuration
12
12
  }
13
13
  }.freeze
14
14
 
15
- def initialize(worklog_file = '~/worklog')
15
+ def initialize(worklog_file = '~/.worklog')
16
16
  @worklog_file = worklog_file
17
17
  if File.exist?(CONFIG_FILE)
18
18
  @config = load_configuration
@@ -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 track` to track a git repository'\
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)
@@ -1,3 +1,3 @@
1
1
  module Herodot
2
- VERSION = '0.1.10'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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
- TRACK_DESCRIPTION = 'This command sets up post commit and post checkout hooks'\
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 [<repository path>]'
33
- c.summary = 'Start tracking a repository'
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 'Start tracking current repository', 'herodot track'
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.1.10
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-03-16 00:00:00.000000000 Z
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.6.10
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.
data/post-checkout DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
- echo 'Logging into worklog'
3
- project=$(pwd)
4
- branch=$(git rev-parse --abbrev-ref HEAD)
5
-
6
- echo "$(date);$project;$branch" >> ~/worklog