Project

General

Profile

Logging time in mercurial commit message doesn't work

Added by Omar Kohl over 13 years ago

I write 'closes #3 @1h30m' in a mercurial commit message and it doesn't log any time. The issue is closed (after having enabled the option in the configuration) but no time is logged. Maybe there is some option/configuration I have to enable? I wasn't able to find any proper instructions about this so I'm not sure. I freshly installed redmine a week ago so it should be the most recent version.


Replies (7)

RE: Logging time in mercurial commit message doesn't work - Added by Toshi MARUYAMA over 13 years ago

Parsing log is scm common operation.
I think this problem is fixed by #7630.

RE: Logging time in mercurial commit message doesn't work - Added by Omar Kohl over 13 years ago

In that issue the only thing mentioned is that time is logged, but wrongly. In my case no time is logged. That is what confuses me. I got Redmine 1.1.2.stable.5131 so it should be the latest release and it should incorporate this functionality right?

RE: Logging time in mercurial commit message doesn't work - Added by Toshi MARUYAMA over 13 years ago

I don't use this feature yet.
If you think this is bug, could you create new defect issue?

RE: Logging time in mercurial commit message doesn't work - Added by Omar Kohl over 13 years ago

First I want to make sure I'm doing nothing wrong. Maybe someone can confirm that it works fine without need for any special configuration.

RE: Logging time in mercurial commit message doesn't work - Added by Maciej Smoliński over 13 years ago

Solution

1) Actually, setting:

Administration > Settings > Repositories > "Activity for logged time" from "Default" to "Development"

should solve your problem :)

2) Remember that your email in ~/.gitconfig file should match the one you are registered with in redmine
To check your email:


    git config --get user.email


To set your email:

    locally (in project folder):
    git config user.email your@email.com

    or globally (anywhere):
    git config --global user.email your@email.com

that's because of a logic (problem?) in a redmine code..


What the problem is?

  1. When log_time(issue, time) method is called, then TimeEntry object is created.
  2. TimeEntry validates presence of :activity_id (TimeEntryActivity).
  3. But TimeEntryActivity ("Default"/"Development"/"Support") is not passed, because of if conditional in log_time_activity method ("Default"'s id is 0).
  4. Because no TimeEntryActivity object is set in TimeEntry, the TimeEntry object is not valid and because of that fact - not inserted into database at all

The code:

app/models/time_entry.rb :


    class TimeEntry < ActiveRecord::Base

      ...

      validates_presence_of ..., :activity_id, ...

      ...

    end

app/models/changeset.rb :


      def log_time(issue, hours)

        time_entry = TimeEntry.new

        ...

        time_entry.activity = log_time_activity unless log_time_activity.nil?

        ...

      end


app/models/changeset.rb :

      def log_time_activity

        if Setting.commit_logtime_activity_id.to_i > 0
          TimeEntryActivity.find_by_id(Setting.commit_logtime_activity_id.to_i)
        end

      end

Hope it solves your problem,
Maciej :)

RE: Logging time in mercurial commit message doesn't work - Added by michele corradin over 12 years ago

hi,
I did what is suggested and now time spent management works again but there are errors in the incremental sum: it seems it doubles the result .. but not always.
Is there a way to make it reset and recalculate everything?
Thanks
Michele

RE: Logging time in mercurial commit message doesn't work - Added by Pieter Noyens over 4 years ago

To add on this:

I had some troubles with time logging via commit messages too. I applied all of the suggested ideas, but still it didn't work. I managed to fix it by specifically assigning the related projects to my user account. I was doing everything via my admin account, so I already had all the privileges to log time etc. for all projects. But the automated logging will only work if the projects are specifically assigned to the user account from which the commits are coming. So you also have to make sure the mapping from git user to redmine user (in case working with an external git repo) is correctly set up!

    (1-7/7)