Skip to content

Commit

Permalink
[#1337] Tracks Pivotal Story IDS.
Browse files Browse the repository at this point in the history
  • Loading branch information
rietta committed Dec 29, 2013
1 parent 6391a33 commit 83b9f98
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
13 changes: 0 additions & 13 deletions Rakefile
@@ -1,18 +1,5 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'

# Hoe.plugin :compiler
# Hoe.plugin :gem_prelude_sucks
# Hoe.plugin :inline
# Hoe.plugin :racc
# Hoe.plugin :rcov
# Hoe.plugin :rubyforge

Hoe.spec 'git_time_extractor' do
developer('Rietta Inc.', 'hello@rietta.com')
# self.rubyforge_name = 'git_time_extractorx' # if different than 'git_time_extractor'
end

# vim: syntax=ruby
44 changes: 40 additions & 4 deletions lib/git_time_extractor.rb
Expand Up @@ -8,13 +8,14 @@
# Portions (C) 2012 Rietta Inc. and licensed under the terms of the BSD license.
#
class GitTimeExtractor
VERSION = '0.2.1'
VERSION = '0.2.2'

require 'rubygems'
require 'ostruct'
require 'logger'
require 'git'
require 'csv'
require 'set'

#
# Go through the GIT commit log, to compute the elapsed working time of each committing developer, based
Expand Down Expand Up @@ -42,24 +43,39 @@ def self.process_git_log_into_time(path_to_git_repo = "./", path_to_output_file
# Go through the GIT commit records and construct the time
log_entries.each_with_index do |commit, index|
author_date = commit.author_date.to_date
daylog = worklog[author_date] || OpenStruct.new(:date => author_date, :duration => 0, :commit_count => 0, :pivotal_stories => [] )
daylog = worklog[author_date] || OpenStruct.new(:date => author_date, :duration => 0, :commit_count => 0, :pivotal_stories => Set.new )
daylog.author = commit.author
daylog.message = "#{daylog.message} --- #{commit.message}"
daylog.duration = daylog.duration + calc_duration_in_minutes(log_entries, index)

# The git commit count
daylog.commit_count += 1

# Pivotal Stories
stories = pivotal_ids(commit.message)
if stories
# It's a set, so each story only gets added once per day
stories.each do |sid|
daylog.pivotal_stories << sid
end
end


worklog[author_date] = daylog
end # log_entries.each_with_index

# Print the header row for the CSV
puts [
'Date',
'Git Commits',
'Git Commits Count',
'Pivotal Stories Count',
'Minutes',
'Hours',
'Person',
'Email',
'Project',
'Notes',
'Pivotal Stories',
'Week Number',
'Year'
].to_csv
Expand All @@ -77,19 +93,21 @@ def self.process_git_log_into_time(path_to_git_repo = "./", path_to_output_file
row = [
start_time.strftime("%m/%d/%Y"),
summary.commit_count,
summary.pivotal_stories.count,
duration_in_minutes,
duration_in_hours,
summary.author.name,
summary.author.email,
project_name,
summary.message,
summary.pivotal_stories.map(&:inspect).join(', '),
start_time.strftime("%W").to_i,
start_time.strftime("%Y").to_i]
puts row.to_csv
end # worklog each

end # process_git_log_into_time

# Calculate the duration of work in minutes
def self.calc_duration_in_minutes(log_entries, index)
commit = log_entries[index]
Expand All @@ -112,4 +130,22 @@ def self.calc_duration_in_minutes(log_entries, index)
def self.say_hi
"hi"
end

# --- [#62749778] New Email Page --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development --- [#62749778] Roughed out email form. --- Added delete Attachment functionality --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development --- [#62749778] Refactored controller to be plural. --- [#62749778] Added to the Email model. --- [62749778] The email this report view formatting. --- [#62749778] Breadcrumbs in the navigation. --- [#62749778] The Emails controller routes. --- The report list is now sorted with newest first - and it shows how long ago that the change was made. --- [#62749778] The share link is bold. --- [#62749778] Recipient parsing and form fields --- [#62749778] List of emails that have received it. --- [#62749778] The email form will validate that at least one email is provided. --- [#62749778] Send Roof Report AJAX form. --- [#62749778] Default messages and the mailer --- [Finishes #62749778] The emails are sent! --- removed delete from show --- added txt and xpf to permitted file types --- Attachments can only be deleted by the owner of the roof report. --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development --- The test server is using production. --- Returns all recommended options across all sections with roof_report.recommedations --- patial commit --- Finished summary section --- Added caps to permitted --- added to_s to inspection --- E-mail spec is not focused at the moment. --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development --- fixed a few bugs --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development --- Disable ajax save. --- Merge branch 'development' of bitbucket.org:rietta/roofregistry-web into development
# s = "[#62749778] [#62749778] [#6274977] [#1] [#231]"
# m = s.scan /\[[A-Za-z ]{0,20}#[0-9]{1,20}\]/
def self.pivotal_ids(text)
stories = Array.new
# Extract the unique ids between brackets
if text
candidates = text.scan /\[[A-Za-z \t]{0,20}#[0-9]{1,35}[ \t]{0,5}\]/
if candidates
candidates.uniq.each do |story|
story_num = story.match(/[0-9]{1,35}/).to_s.to_i
stories << story_num if story_num > 0
end
end
end
stories.sort
end
end # class GitTimeExtractor

0 comments on commit 83b9f98

Please sign in to comment.