Module: GitmeTime

Defined in:
lib/gitme_time.rb,
lib/gitme_time/config.rb,
lib/gitme_time/errors.rb,
lib/gitme_time/cli/app.rb,
lib/gitme_time/version.rb,
lib/gitme_time/cli/init_tutorial.rb

Defined Under Namespace

Modules: CLI, Config Classes: InvalidRepo

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.create_entry_for_last_commitObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitme_time.rb', line 9

def self.create_entry_for_last_commit
  commit = last_commit
  hours  = nil
  match = commit.message.match /(.*)\[([\w\:\.]+)\]\s*$/
  if match
    message, hours = match[1], match[2]
  elsif Config.track_empty_hours?
    message = commit.message
    hours = 0
  end
  # hours is nil when commit does not have hours specification and
  # we do not have to track empty hours
  if hours
    message << " [#{current_branch} #{commit.sha[0,6]}]"
    create_entry message, :hours => hours
  else
    puts "  TimeEntry creation ignored (no hours specification in commit)"
  end
end