-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpost_commit_hook.rb
More file actions
38 lines (26 loc) · 854 Bytes
/
post_commit_hook.rb
File metadata and controls
38 lines (26 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
require 'grit'
include Grit
puts 'Running tigger....'
puts 'Matching tasks and commit messages.'
repo = Repo.new('./')
commits = repo.commits
tigger = File.new('.tigger', 'r')
tasks = Array.new
completed_tasks = Array.new
tigger.each_line { |line| tasks << line }
commit = commits.last
tasks.each do | task |
if (commit.message.strip.upcase.index(task.strip.upcase) != nil)
completed_tasks << (Time.now.to_i.to_s + "<?TIG?>" + task)
tasks.delete task
puts('Completed task: ' + task.strip + '.')
end
end
tigger.close
tigger = File.new('.tigger', 'w')
tasks.each { |task| tigger.write task }
tigger.close
tigger_completed = File.new('.tigger_completed', 'a+')
completed_tasks.each { |task| tigger_completed.write task }
tigger_completed.close