git_timer 0.0.1 → 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 +4 -4
- data/lib/git_timer/cli.rb +11 -5
- data/lib/git_timer/version.rb +1 -1
- data/lib/git_timer.rb +8 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57df702d08bbadfdbdf1112c1b2e045d18b947d6
|
4
|
+
data.tar.gz: 3322ceb55b9bee5ec3dbfff1070072bc84229e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bae838271839cf660b8bf7e018d3a165ea483ff2795877fa1bd92da261e15058710a717e9e72878d71cc965574adc5ed25581b2f17bad8701b56de9d91bb54
|
7
|
+
data.tar.gz: 550329039fd5d9476764f0d915474a7bfc1dc545aadb72ab6595394c9c7273f4d936e9c68413c70f0d70ffe2f2a3318d37959558c4dd9c008be6788b71d32003
|
data/lib/git_timer/cli.rb
CHANGED
@@ -5,16 +5,22 @@ module GitTimer
|
|
5
5
|
desc "work ACTION", "This will start or stop your work tracking"
|
6
6
|
long_desc <<-WORK
|
7
7
|
|
8
|
-
`work start` will insert 'Work
|
8
|
+
`work start` will insert 'Work | Start | 2018-01-01 00:00:00 -0300' in the user-log file
|
9
9
|
|
10
|
-
`work stop` will insert 'Work
|
10
|
+
`work stop` will insert 'Work | Stop | 2018-01-01 00:00:00 -0300' in the user-log file
|
11
11
|
|
12
12
|
With the timestamp being the current time with the format %yyyy-MM-dd hh:mm:ss time_zone
|
13
13
|
WORK
|
14
|
-
|
14
|
+
|
15
15
|
def work(action)
|
16
|
-
|
17
|
-
|
16
|
+
case action
|
17
|
+
when 'start', 'START', 'Start'
|
18
|
+
GitTimer.register_activity({ ticket_id: 'Work', ticket_state: 'Start' })
|
19
|
+
when 'stop', 'STOP', 'Stop'
|
20
|
+
GitTimer.register_activity({ ticket_id: 'Work', ticket_state: 'Stop' })
|
21
|
+
else
|
22
|
+
puts 'Invalid action, please use `git_timer start` or `git_timer stop`. Type `git_timer help` for more information.'
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/git_timer/version.rb
CHANGED
data/lib/git_timer.rb
CHANGED
@@ -5,19 +5,20 @@ module GitTimer extend self
|
|
5
5
|
require 'fileutils'
|
6
6
|
require 'time'
|
7
7
|
|
8
|
-
MAIN_PATH = '
|
8
|
+
MAIN_PATH = '.git/user-log'
|
9
9
|
PRE_PUSH_PATH = '.git/hooks/pre-push'
|
10
10
|
POST_CHECKOUT_PATH = '.git/hooks/post-checkout'
|
11
11
|
LOG_TITLE = "# Git log \n"
|
12
12
|
|
13
13
|
def main
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
unless File.exist?(MAIN_PATH)
|
15
|
+
File.open(MAIN_PATH, 'w+') do |f|
|
16
|
+
f.write LOG_TITLE
|
17
|
+
end
|
18
|
+
File.chmod(0777, MAIN_PATH)
|
17
19
|
end
|
18
|
-
|
19
|
-
initialize_git_hook(
|
20
|
-
initialize_git_hook(PRE_PUSH_PATH, 'pre_push')
|
20
|
+
initialize_git_hook(POST_CHECKOUT_PATH, 'post_checkout') unless File.exist?(POST_CHECKOUT_PATH)
|
21
|
+
initialize_git_hook(PRE_PUSH_PATH, 'pre_push') unless File.exist?(PRE_PUSH_PATH)
|
21
22
|
end
|
22
23
|
|
23
24
|
def initialize_git_hook(hook_path, hook_method)
|