Redmine Time logging via commit checklist

Redmine has a very handy feature, called Time tracking feature, that allows you to log the time your spent working on a code via a commit message. However, it didn’t fly out-of-the-box in my case. If you find yourself in a similar situation you could take a look at the checklist below to verify that you’ve set all required options correctly. That helped me (I had redmine 2.3.4), but there is no guarantee it would work in your particular case but at least you could be sure that all knobs are in the right positions.

  1. Go to Administration > Settings > Projects
  2. Check the “Time tracking” module has been selected in “Default enabled modules for new projects”.
    Also prove that it’s enable for your project by going to Project > Settings > Modules and verify that “Time tracking” is enabled there.

  3. Go to Administration > Settings > Repositories
  4. Make sure that “Enable time logging” check box is ticked and “Activity for logged time” is set to anything but not “Default”.
    Remember what keywords are listed in the “Referencing keywords” and “Fixing keywords” fields.

  5. If you use git verify that your email in ~/.gitconfig matches with the email of your account in Redmine.
  6. The same is true not only for git but for other SVC. As a workaround you could use Repository-user-mapping To reach it, go to Project > Settings > Repositories and on the right hand side you will see three links: Users, Edit and Delete. Clicking on “Users” will forward you to a page where you could map a Redmine user to a username found in the repository log.

  7. Make sure that a user in Redmine has enough permissions to log spent time
  8. Go to Administration > Settings > Users and there you could check various roles and permissions which have been applied to your Redmine account, as well as the groups he/she is the member of. Look for “Time tracking” permissions:


  9. Finally, double check that you use proper keywords (remember step 2?)
  10. For example:

    refs #3118 @2h
  11. As the last resort (if you are fine with digging into a Ruby code) you could take a look at app/models/changeset.rb, especially at def scan_comment_for_issue_ids() function and add extra logging to make sure that the comment string is parsed properly and hours variable is not empty:
    comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
          action, refs = match[2], match[3]
          next unless action.present? || ref_keywords_any
          refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
            issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
            if issue
              referenced_issues << issue
              fix_issue(issue) if fix_keywords.include?(action.to_s.downcase)
              log_time(issue, hours) if hours && Setting.commit_logtime_enabled?

Good luck!

Posted on January 16, 2015 at 3:15 pm by sergeyt · Permalink
In: Uncategorized

Leave a Reply