Feature #4155
closedAutomatic spent time logging from commit messages
Added by Marek Siller about 15 years ago. Updated over 12 years ago.
100%
Description
We have created a small patch for redmine that enables automatic logging of spent time via commit messages of a versioning system.
Use case¶
This patch allows users to log the spent time automatically along with commiting their work to the SCM. It works in a similar way like referencing or closing issues via commit messages. For example:
Fixed some issue with menu. refs #1234 @2h30m
The user does not have to visit the redmine site just to log the spent time any more.
Features¶
- Support for both ways of referencing issues - with keywords (refs, fixes, ...) and with wildcard.
- Possibility to turn the feature on or off (default is the original behavior of redmine).
- Support for two time formats: as a floating point number (i. e. 2.5) or as a string (i. e. 2h30m or 2h 30m). Time specification must follow the issue reference (blanks allowed). Examples
refs #1234 @2.5 references #1234 @2h30m fixes #1234 @2h 30m
- Date of logged spent time - date of commit.
- Owner of logged spent time - user mapped to the SCM account the commit belongs to.
- Uses default (or the first found if no default set) activity for spent time logging.
- Comment for logged spent time includes the revision number.
Patch¶
Tested with Redmine 0.8.5 and the latest development version (both patches included). Tested SCM include Subversion and git.
Patched files¶
- app/models/changeset.rb
- app/views/settings/_repositories.rhtml
- config/settings.yml (new configuration option: Enable spent time logging)
- + language files (two new messages - setting_commit_logtime_enabled and text_commit_logtime) - already translated to German and Czech
Any feedback or question is welcome!
Sincerelly Yours,
Marek Siller
Karlsruhe Technology Consulting
Files
LogTime-v1-redmine-0.8.5.patch (27.8 KB) LogTime-v1-redmine-0.8.5.patch | Patch for version 0.8.5 | Marek Siller, 2009-11-02 16:45 | |
LogTime-v1-redmine-devel.patch (30.2 KB) LogTime-v1-redmine-devel.patch | Patch for trunk version | Marek Siller, 2009-11-02 16:45 | |
LogTime-v2-redmine-0.8.x.patch (27.8 KB) LogTime-v2-redmine-0.8.x.patch | Patch for version 0.8.x (tested on 0.8.5 and 0.8.6) | Marek Siller, 2009-11-04 16:46 | |
LogTime-v2-redmine-devel.patch (30.2 KB) LogTime-v2-redmine-devel.patch | Patch for trunk version | Marek Siller, 2009-11-04 16:46 | |
LogTime-v2.1-redmine-0.8.x.patch (27.8 KB) LogTime-v2.1-redmine-0.8.x.patch | Patch for version 0.8.x (tested on 0.8.5 and 0.8.6) - corrected version | Marek Siller, 2009-11-06 18:09 | |
LogTime-v2.1-redmine-devel.patch (30.2 KB) LogTime-v2.1-redmine-devel.patch | Patch for trunk version - corrected version | Marek Siller, 2009-11-06 18:09 | |
LogTime-v2.1-redmine-devel.patch (30.2 KB) LogTime-v2.1-redmine-devel.patch | Patch for trunk version - corrected version | Marek Siller, 2009-11-06 18:45 | |
logtime_redmine_0.9.2.patch (22.3 KB) logtime_redmine_0.9.2.patch | Vladimir Kovacik, 2010-02-18 14:00 | ||
logtime_redmine_0.9.2_v2.2.patch (22.3 KB) logtime_redmine_0.9.2_v2.2.patch | Vladimir Kovacik, 2010-03-04 10:13 | ||
logtime_redmine_0.9.2_v2.3.patch (22.7 KB) logtime_redmine_0.9.2_v2.3.patch | Katy A, 2010-05-25 01:45 | ||
logtime_redmine_0.9.3_v2.3.patch (22.2 KB) logtime_redmine_0.9.3_v2.3.patch | Paul Widden, 2010-09-01 19:33 | ||
logtime_redmine_1.0.3-v3.patch (114 KB) logtime_redmine_1.0.3-v3.patch | Marek Siller, 2010-11-09 20:13 | ||
fix-scmid-all-number.diff (1.8 KB) fix-scmid-all-number.diff | Toshi MARUYAMA, 2010-12-11 14:51 |
Related issues
Updated by Marek Siller about 15 years ago
The biggest difference between this patch / feature and the related feature #1518 is that the syntax in commit message is (in my opinion) a little bit simpler (no new keywords, just an at-sign) and it allows the developer explicit specification of the spent time for each referenced issue - for instance
Completed implementation of two new features: refs #1518 @3h 40m #4155 @6h
Updated by Marek Siller about 15 years ago
Updated by Jean-Philippe Lang about 15 years ago
I think this feature should be added in 0.9.
Another patch for this feature was already submitted in #1518.
Please have a look at its description: http://www.redmine.org/issues/1518#note-14
Here is an exemple:
refs #1 ratio 50 time 1,0 timelogcomment comment for this timelog
I have to admit that I prefer the shorter syntax:
refs #1234 @2.5 references #1234 @2h30m fixes #1234 @2h 30m
What do you think? Any suggestion is welcome.
Updated by Robert Chady about 15 years ago
Personally, I prefer the the shorter syntax, not only for its use, but simplicity of the patch. For those that want something other than the '@' token, it should be possible to make this a settable option (which token or string to use).
The only other option I see that would be nice is to be able to make the comment get updated in the journal AND the comment if possible -- or something similar. I would not want to see a bunch of things getting inserted via comments and not show up in the journal as well from this.
Updated by Jonas von Andrian about 15 years ago
Hi,
I started the other patch.
I like the shorter syntax, but this patch lacks another feature, which might be nice to have: Assigning ratios via commit messages.
Plus it has no tests.
Apart from that I would prefer this patch, since it's up to date.
Updated by Marek Siller about 15 years ago
Thanks for the feedback!
Robert Chady wrote:
Personally, I prefer the the shorter syntax, not only for its use, but simplicity of the patch. For those that want something other than the '@' token, it should be possible to make this a settable option (which token or string to use).
I will add the new setting in next version of this patch. You're right, it'd be nice if redmine users could define their own token / keyword for spent time logging.
The only other option I see that would be nice is to be able to make the comment get updated in the journal AND the comment if possible -- or something similar. I would not want to see a bunch of things getting inserted via comments and not show up in the journal as well from this.
I will investigate how this can be done.
Jonas von Andrian wrote:
Hi,
I started the other patch.I like the shorter syntax, but this patch lacks another feature, which might be nice to have: Assigning ratios via commit messages.
Unfortunately, I have no idea, what you mean with assigning ratios via commit messages - could you ellaborate on this subject, please.
Plus it has no tests.
You're right, there are no tests right now, I'm planning on including them in the next version of the patch.
Apart from that I would prefer this patch, since it's up to date.
Updated by Erik Lindblom about 15 years ago
Marek,
I applied the patch, but I'm having issues with it.
Here is the top of the error log:
NoMethodError (undefined method `match' for 0:Fixnum): app/models/changeset.rb:144:in `scan_comment_for_issue_ids' app/models/changeset.rb:138:in `each' app/models/changeset.rb:138:in `scan_comment_for_issue_ids' app/models/changeset.rb:70:in `after_create' app/models/repository/subversion.rb:59:in `fetch_changesets' app/models/repository/subversion.rb:58:in `fetch_changesets' app/models/repository/subversion.rb:57:in `reverse_each' app/models/repository/subversion.rb:57:in `fetch_changesets' app/controllers/repositories_controller.rb:70:in `show'
Any ideas?
I have my "Referencing keywords" set to "*" because I just commit with "(#idnumber)"
Updated by Marek Siller about 15 years ago
Erik Lindblom wrote:
Marek,
I applied the patch, but I'm having issues with it.
Here is the top of the error log:
[...]
Any ideas?
I have my "Referencing keywords" set to "*" because I just commit with "(#idnumber)"
Thanks for letting me know about the bug.
I'll investigate the source of the problem and let you know. Which redmine version do you use and which patch have you applied (version 1 or the updated version 2)?
Updated by Marek Siller about 15 years ago
- File LogTime-v2.1-redmine-0.8.x.patch LogTime-v2.1-redmine-0.8.x.patch added
- File LogTime-v2.1-redmine-devel.patch LogTime-v2.1-redmine-devel.patch added
Erik Lindblom wrote:
Version: 0.8.6.devel.3009
Patch v22
I've found the problem and fixed it. New set of patches included. Could you test it and let me know whether it solves your problem, please?
Updated by Erik Lindblom about 15 years ago
Marek Siller wrote:
Erik Lindblom wrote:
Version: 0.8.6.devel.3009
Patch v22I've found the problem and fixed it. New set of patches included. Could you test it and let me know whether it solves your problem, please?
Tested it and still get an error, here is the log:
ArgumentError (wrong number of arguments (1 for 0)): app/models/changeset.rb:164:in `default' app/models/changeset.rb:164:in `scan_comment_for_issue_ids' app/models/changeset.rb:138:in `each' app/models/changeset.rb:138:in `scan_comment_for_issue_ids' app/models/changeset.rb:70:in `after_create' app/models/repository/subversion.rb:59:in `fetch_changesets' app/models/repository/subversion.rb:58:in `fetch_changesets' app/models/repository/subversion.rb:57:in `reverse_each' app/models/repository/subversion.rb:57:in `fetch_changesets' app/controllers/repositories_controller.rb:70:in `show'
Updated by Marek Siller about 15 years ago
Sorry, I made a mistake while creating the patch for the devel version. Corrected version in attachement.
Updated by Erik Lindblom about 15 years ago
Great. Thanks! It applies now with no errors, however, none of the time shows up on the tickets.
I've tried (#112) 2 2 and even the older one, refs #112 2 2 and neither of them log time against the ticket.
Is there any more configuration I need besides the option on the administration screen?
Thanks for your time on this!
Updated by Leonard Brünings about 15 years ago
Updated by Erik Lindblom about 15 years ago
Just tried this with no luck:
testing (#362) @2h
Updated by Mischa The Evil about 15 years ago
Erik Lindblom wrote:
Just tried this with no luck:
testing (#362) @2h
I think this is due to the used parentheses in you syntax. Probably
testing #362 @2hworks...
Updated by Erik Lindblom about 15 years ago
Mischa The Evil wrote:
Erik Lindblom wrote:
Just tried this with no luck:
[...]
I think this is due to the used parentheses in you syntax. Probably [...] works...
Very odd, I've tried it with that syntax and still nothing. I've also tried on a clean checkout and still doesn't work. There is nothing in the logs as well :/
If anyone has any suggestions, I would love to hear them.
Updated by Jean-Philippe Lang about 15 years ago
Adding a few tests in this patch would lower the noise.
Updated by Jonas von Andrian about 15 years ago
Marek Siller wrote:
Jonas von Andrian wrote:
I like the shorter syntax, but this patch lacks another feature, which might be nice to have: Assigning ratios via commit messages.
Unfortunately, I have no idea, what you mean with assigning ratios via commit messages - could you ellaborate on this subject, please.
It's possible to set a percentage (ratio to 1) how far the ticket has progressed (% Done). I think it would be nice to be able to set that too via the commit message.
Updated by Chris Platts almost 15 years ago
Erik Lindblom wrote:
Mischa The Evil wrote:
Erik Lindblom wrote:
Just tried this with no luck:
[...]
I think this is due to the used parentheses in you syntax. Probably [...] works...
Very odd, I've tried it with that syntax and still nothing. I've also tried on a clean checkout and still doesn't work. There is nothing in the logs as well :/
If anyone has any suggestions, I would love to hear them.
Hi,
Just for info, I'm seeing this problem behaviour too - patch apparently applies OK, but time entries are not logged. I'm running the latest SVN version as of today (0.8.7.devel.3111)
Cheers,
Chris
Updated by Sachin Khandelwal almost 15 years ago
Chris Platts wrote:
Erik Lindblom wrote:
Mischa The Evil wrote:
Erik Lindblom wrote:
Just tried this with no luck:
[...]
I think this is due to the used parentheses in you syntax. Probably [...] works...
Very odd, I've tried it with that syntax and still nothing. I've also tried on a clean checkout and still doesn't work. There is nothing in the logs as well :/
If anyone has any suggestions, I would love to hear them.
Hi,
Just for info, I'm seeing this problem behaviour too - patch apparently applies OK, but time entries are not logged. I'm running the latest SVN version as of today (0.8.7.devel.3111)
Cheers,
Chris
Hi,
I'm trying to apply the below mentioned patch to redmine source checkout from "http://redmine.rubyforge.org/svn/tags/0.8.6" using TortoiseSVN.
"LogTime-v2.1-redmine-0.8.x.patch - Patch for version 0.8.x (tested on 0.8.5 and 0.8.6) - corrected version (27.8 KB) Marek Siller, 2009-11-06 22:39"
Its giving error "The line indicating the new file is expected in line 3". The format of your patch file seems little different from normal. Please help me to track where I'm going wrong.
Regards,
Sachin
Updated by Renzo Meister almost 15 years ago
Hi,
I've installed it and after some trial and errors it works fine.
But for my use there is one "bug" or better a feature wish.
I'm working with subprojects so it must be possible to log time for a ticket which is in another project.
I think the problem is in changeset.rb:...
timeentry = TimeEntry.create(:project => repository.project,
:issue => issue,
...
Here it uses the project of current repository but for me it's better to use the project of the issue.
Does anybody know how I get the project of my issue and use it?
Regards
Renzo
Updated by Vladimir Kovacik almost 15 years ago
Since last released patch (LogTime-v2.1-redmine-devel.patch) does not apply correctly on the latest Redmine trunk I have updated the patch and tested on Redmine 0.9.2 (111 2342)
The main issue was related to the following part:
+ if activity == nil + activity = TimeEntryActivity.values[0] + end
There was also an issue with time getting logged twice when [Referencing keywords] is set to "*". This happens because log_time variable got first time filled when handling "ref_keywords=*" and second time when handling ref+fix keywords. This is fixed in the attached patch.
Updated by Tomasz Sawicki over 14 years ago
Very nice feature, thank you for contributing.
Another nice thing would be possibility to log the time without referencing particular issue, like:
- doing some cleanups @2h30m
so I can log the time spent on something that is not in any issue.
It's just like filling Spent time form without providing issue Id.
Updated by Tomasz Sawicki over 14 years ago
After applying the patch you must include the "spent time" part, otherwise reference to issue will be ignored. Following won't work anymore:
refs #4155
To fix that following line:
target_issues_with_log = match[1].scan(/([\s,;&]*([^@]|#?)\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))/)
should be changed to:
target_issues_with_log = match[1].scan(/([\s,;&]*([^@]|#?)\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?/)
(additional question mark near the end of line)
Updated by Vladimir Kovacik over 14 years ago
Thanks for pointing this issue out. The updated patch is included. Now issue reference is handled correctly even when "Time Spent" is not included and Referencing keywords are defined (different than *, e.g. refs).
Updated by Simon Dyson over 14 years ago
Is there a version of this patch compatible with Redmine 0.9.3?
Updated by Katy A over 14 years ago
Here it uses the project of current repository but for me it's better to use the project of the issue.
Does anybody know how I get the project of my issue and use it?
The updated patch is considering the project of the issue and work with subprojects too.
Updated by Paul Widden about 14 years ago
Patch for 0.9.3
Updated by Dominic Clifton about 14 years ago
Does the current patch apply on 1.0.3 or is a new one required?
When will this be integrated into trunk or is there other similar functionality that should be used instead?
Updated by Dominic Clifton about 14 years ago
Current patch applies with:
cd /path/to/redmine wget http://www.redmine.org/attachments/download/4410/logtime_redmine_0.9.3_v2.3.patch patch -p 0 -F 3 < logtime_redmine_0.9.3_v2.3.patch
My other questions above still stand.
Updated by Marek Siller about 14 years ago
- corrected regular expressions for spent time logging
- function scan_comment_for_issue_ids split into several functions for easier reading and to make it testable
- set of tests that check the functionality
- logging of spent time creates a new journal entry (activity) associated with the referenced issue (can be switched off in settings)
- the activity type (e.g. Development, Design) the spent time is logged on, can be configured in the settings
The patch has been tested both with experimental subversion setup as well as with the test suite, all tests were successful. Tested with stable version of Redmine (1.0.3) and development version from trunk.
Every feedback regarding the patch and / or feature requests would be greatly appreciated.
Is there any chance, this patch makes it to the main repository of Redmine? What needs to be done in order to get it in the main repository?
Updated by Jean-Philippe Lang about 14 years ago
- Category changed from SCM to Time tracking
- Assignee set to Jean-Philippe Lang
- Target version set to 1.1.0
I'll review your patch as soon as possible.
Updated by Jean-Philippe Lang about 14 years ago
- Tracker changed from Patch to Feature
Updated by Ivan Cenov almost 14 years ago
I am translating this to Bulgarian and have a question:
text_time_logged_by_changeset: Applied in changeset {{value}}.
What kind is the value of value ? What information does it comprises of?
Ivan
Updated by Marek Siller almost 14 years ago
The value includes the revision number from the commit / changeset - for example r123 for revision 123.
Marek
Ivan Cenov wrote:
I am translating this to Bulgarian and have a question:
[...]What kind is the value of value ? What information does it comprises of?
Ivan
Updated by Toshi MARUYAMA almost 14 years ago
Updated by Jean-Philippe Lang almost 14 years ago
- Status changed from New to Closed
- % Done changed from 90 to 100
Implementation was rewritten based on the provided patch.
A few things were changed/removed for consistency (like notes in the issue history, as they are not added when logging time through the UI).
Basically, it works as expected. The syntax is the same as the one you can use to log time through the UI (see RedmineTimeTracking), except that spaces are not allowed to keep parsing simple.
Thanks.
Updated by гиём шарьм almost 14 years ago
Is it posisble to update the patch for redmine 1.1?
Thanks.
Updated by Marek Siller almost 14 years ago
гиём шарьм wrote:
Is it posisble to update the patch for redmine 1.1?
Thanks.
The patch is already included in redmine version 1.1, as far as I know.
Sincerely,
Marek Siller
KTC - Karlsruhe Technology Consulting GmbH (www.k-tc.de)
Updated by гиём шарьм almost 14 years ago
I saw indeed something in administration/settings/repositories : Enable time logging. I tried it but without any result. Do the syntax has changed? Or does it simply does not work with mercurial?
Updated by Marek Siller almost 14 years ago
гиём шарьм wrote:
I saw indeed something in administration/settings/repositories : Enable time logging. I tried it but without any result. Do the syntax has changed? Or does it simply does not work with mercurial?
It should work with Mercurial as well. Which syntax do you use - as far as I know, Jean-Philippe Lang changed the syntax a little bit - no spaces are allowed in the spent time entry ... but something like
Here is my change refs #1234 @1h30m
should work without any problems.
What expression do you use in the commit message?
Updated by гиём шарьм almost 14 years ago
Updated by Marek Siller almost 14 years ago
гиём шарьм wrote:
I indeed didn't try this syntax.
But I tried
ref #1234 @2h
and it does not work.By the way, ref #1234 @XhYYm Apply only Xh and 0 min. Is it normal?
Is there any ratio or timelogcomment command still?
I have to go through the code to answer you question - I'm not completely familiar with the way the time-logging in redmine 1.1 - we still use 1.0.3 with the patch I wrote ... but I will try it tommorow and get back to you, how the syntax should exactly work ... and if it does not work work for you in connection with Mercurial, you should create a new issue / ticket here, so that the developers can track the bug. Even if you create new ticket, I'll be glad to help you to get it working (just add me to the watch list or send me an email with the link at marek.siller@k-tc.de)
Sincerely,
Marek Siller
KTC - Karlsruhe Technology Consulting GmbH
Updated by Terence Mill over 13 years ago
For this new feature documentation is still missing in wiki redmine user guide
See RedmineTimeTracking or RedmineIssues
Updated by Szymon Nowak about 13 years ago
I there any way to apply this patch to Redmine 1.2.1? Is it working with 1.2.1?
Updated by Daniel Dehennin almost 13 years ago
Is there a way to specify the activity in the commit messages?
It is defaulted to Developpment but sometimes it could be usefull to change it.
Regards.
Updated by michele corradin over 12 years ago
Hi,
we have moved to version 1.3.2 from an old version patched but it's no more working the syntax "#issue @Xh" in the SVN logging.
I didn't understand from the last post if time tracking is working or not in new versions, can you give me a feedback?
We are really using it a lot
Thanks
michele
Updated by Jean-Philippe Lang over 12 years ago
The syntax "#issue @Xh" should work fine. Make sure that "Enable time logging" option is enabled in Application settings -> Repositories.