Project

General

Profile

Feature #4155 » logtime_redmine_0.9.3_v2.3.patch

Paul Widden, 2010-09-01 19:33

View differences:

app/models/changeset.rb (working copy)
90 90
    
91 91
    referenced_issues = []
92 92
    
93
    log_time = []
94

  
95
    logger.debug "Changeset comment: #{comments}" if logger && logger.debug?
96

  
93 97
    if ref_keywords.delete('*')
94 98
      # find any issue ID in the comments
95 99
      target_issue_ids = []
96
      comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
100
      comments.scan(%r{([\s\(\[,-]|^)#(\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?(?=[[:punct:]]|\s|<|$)}).each do |m|
101
        target_issue_ids << m[1]
102
        log_time << [m[1], (m[2] != nil ? m[2].scan(/(\d+[.]\d+|(\d+[hm]\s?){1,2})/)[0][0] : 0)]
103
      end
97 104
      referenced_issues += find_referenced_issues_by_id(target_issue_ids)
98 105
    end
99 106
    
100
    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
107
    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+((([\s,;&]*([^@]|#?)\\d+)([\s]*@(\\d+[.]\\d+|(\\d+[hm]\s?){1,2}))?)+)", Regexp::IGNORECASE)).each do |match|
101 108
      action = match[0]
102
      target_issue_ids = match[1].scan(/\d+/)
109
 
110
      target_issues_with_log = match[1].scan(/([\s,;&]*([^@]|#?)\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?/)
111
      target_issues_with_log.collect! { |x| [ x[0].scan(/\d+/)[0], (x[2] != nil ? x[3].scan(/(\d+[.]\d+|(\d+[hm]\s?){1,2})/)[0][0] : 0) ] }
112

  
113
      log_time += target_issues_with_log
114
 
115
      target_issue_ids = target_issues_with_log.collect {|x| x[0]}
116
  
103 117
      target_issues = find_referenced_issues_by_id(target_issue_ids)
104 118
      if fix_keywords.include?(action.downcase) && fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
105 119
        # update status of issues
106
        logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
120
        logger.debug "Issues fixed by changeset #{self.revision}: #{target_issue_ids.join(', ')}." if logger && logger.debug?
107 121
        target_issues.each do |issue|
108 122
          # the issue may have been updated by the closure of another one (eg. duplicate)
109 123
          issue.reload
......
123 137
          issue.save
124 138
        end
125 139
      end
140
      
126 141
      referenced_issues += target_issues
127 142
    end
143

  
144
    if Setting.commit_logtime_enabled?
145
      log_time.uniq.each do |issue_wl|
146
        next if issue_wl[1] == nil || issue_wl[1] == 0
147

  
148
        issue_id = issue_wl[0]
149
        issue_hours = issue_wl[1]
150

  
151
        match = issue_hours.match(/\d+[.]\d+/)
152

  
153
        if match != nil
154
          issue_hours = match[0].to_f
155
        else
156
          hours = ((match = issue_hours.scan(/(\d+)h/)).size == 1 ? match[0][0] : 0)
157
          minutes = ((match = issue_hours.scan(/(\d+)m/)).size == 1 ? match[0][0] : 0)
158

  
159
          hours = (hours == nil ? 0 : hours.to_i)
160
          minutes = (minutes == nil ? 0 : minutes.to_i)
161

  
162
          issue_hours = ((hours.to_f + minutes.to_f / 60.0) * 100.0).round / 100.0
163
        end
164

  
165
        next if issue_hours.to_f <= 0
166

  
167
        logger.debug "Log time for issue #{issue_id} - #{issue_hours}." if logger && logger.debug?
168

  
169
        issue = Issue.find_by_id(issue_id)
170

  
171
        activity = TimeEntryActivity.default
172
        if activity == nil
173
          activity = TimeEntryActivity.find(:first)
174
        end
175

  
176
        next if activity == nil || issue == nil || user == nil
177

  
178
        csettext = "from revision r#{self.revision}"
179
        if self.scmid && (! (csettext =~ /^r[0-9]+$/))
180
          csettext = "from revision \"#{self.scmid}\""
181
        end
182

  
183
        timeentry = TimeEntry.create(:project => issue.project,
184
                                     :issue => issue,
185
                                     :user => user,
186
                                     :spent_on => self.commit_date,
187
                                     :hours => issue_hours,
188
                                     :activity_id => activity.id,
189
                                     :comments => csettext)
190

  
191
	timeentry.save
192
      end
193
    end
128 194
    
129 195
    referenced_issues.uniq!
130 196
    self.issues = referenced_issues unless referenced_issues.empty?
app/views/settings/_repositories.rhtml (working copy)
31 31
&nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %>
32 32
&nbsp;<%= l(:field_done_ratio) %>: <%= setting_select :commit_fix_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %>
33 33
<br /><em><%= l(:text_comma_separated) %></em></p>
34

  
35
<p><label><%= l(:setting_commit_logtime_enabled) %></label>
36
<%= hidden_field_tag 'settings[commit_logtime_enabled]', 0 %><%= check_box_tag 'settings[commit_logtime_enabled]', 1, Setting.commit_logtime_enabled? %>
37
<br /><em><%= l(:text_commit_logtime) %></em></p>
34 38
</fieldset>
35 39

  
36 40
<%= submit_tag l(:button_save) %>
config/settings.yml (working copy)
96 96
  default: 0
97 97
commit_fix_done_ratio:
98 98
  default: 100
99
commit_logtime_enabled:
100
  format: int
101
  default: 0
99 102
# autologin duration in days
100 103
# 0 means autologin is disabled 
101 104
autologin:
config/locales/ro.yml (working copy)
831 831
  field_active: Active
832 832
  enumeration_system_activity: System Activity
833 833
  permission_delete_issue_watchers: Delete watchers
834
  setting_commit_logtime_enabled: Enable time logging
835
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
836

  
834 837
  version_status_closed: closed
835 838
  version_status_locked: locked
836 839
  version_status_open: open
config/locales/zh.yml (working copy)
377 377
  permission_view_issue_watchers: 查看跟踪者列表
378 378
  permission_add_issue_watchers: 添加跟踪者
379 379
  permission_delete_issue_watchers: 删除跟踪者
380
  setting_commit_logtime_enabled: Enable time logging
381
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
382

  
380 383
  permission_log_time: 登记工时
381 384
  permission_view_time_entries: 查看耗时
382 385
  permission_edit_time_entries: 编辑耗时
config/locales/pt.yml (working copy)
846 846
  field_active: Active
847 847
  enumeration_system_activity: System Activity
848 848
  permission_delete_issue_watchers: Delete watchers
849
  setting_commit_logtime_enabled: Enable time logging
850
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
851

  
849 852
  version_status_closed: closed
850 853
  version_status_locked: locked
851 854
  version_status_open: open
config/locales/ca.yml (working copy)
831 831
  field_active: Active
832 832
  enumeration_system_activity: System Activity
833 833
  permission_delete_issue_watchers: Delete watchers
834
  setting_commit_logtime_enabled: Enable time logging
835
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
836

  
834 837
  version_status_closed: closed
835 838
  version_status_locked: locked
836 839
  version_status_open: open
config/locales/tr.yml (working copy)
861 861
  field_active: Active
862 862
  enumeration_system_activity: System Activity
863 863
  permission_delete_issue_watchers: Delete watchers
864
  setting_commit_logtime_enabled: Enable time logging
865
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
866

  
864 867
  version_status_closed: closed
865 868
  version_status_locked: locked
866 869
  version_status_open: open
config/locales/el.yml (working copy)
834 834
  field_active: Active
835 835
  enumeration_system_activity: System Activity
836 836
  permission_delete_issue_watchers: Delete watchers
837
  setting_commit_logtime_enabled: Enable time logging
838
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
839

  
837 840
  version_status_closed: closed
838 841
  version_status_locked: locked
839 842
  version_status_open: open
config/locales/en.yml (working copy)
885 885
  enumeration_doc_categories: Document categories
886 886
  enumeration_activities: Activities (time tracking)
887 887
  enumeration_system_activity: System Activity
888
  setting_commit_logtime_enabled: Enable time logging
889
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
888 890

  
891

  
config/locales/gl.yml (working copy)
854 854
  field_active: Active
855 855
  enumeration_system_activity: System Activity
856 856
  permission_delete_issue_watchers: Delete watchers
857
  setting_commit_logtime_enabled: Enable time logging
858
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
859

  
857 860
  version_status_closed: closed
858 861
  version_status_locked: locked
859 862
  version_status_open: open
config/locales/cs.yml (working copy)
834 834
  field_active: Active
835 835
  enumeration_system_activity: System Activity
836 836
  permission_delete_issue_watchers: Delete watchers
837
  setting_commit_logtime_enabled: Enable time logging
838
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
839

  
837 840
  version_status_closed: closed
838 841
  version_status_locked: locked
839 842
  version_status_open: open
config/locales/it.yml (working copy)
841 841
  field_active: Active
842 842
  enumeration_system_activity: System Activity
843 843
  permission_delete_issue_watchers: Delete watchers
844
  setting_commit_logtime_enabled: Enable time logging
845
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
846

  
844 847
  version_status_closed: closed
845 848
  version_status_locked: locked
846 849
  version_status_open: open
config/locales/sk.yml (working copy)
833 833
  field_active: Active
834 834
  enumeration_system_activity: System Activity
835 835
  permission_delete_issue_watchers: Delete watchers
836
  setting_commit_logtime_enabled: Enable time logging
837
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
838

  
836 839
  version_status_closed: closed
837 840
  version_status_locked: locked
838 841
  version_status_open: open
config/locales/sl.yml (working copy)
830 830
  field_active: Active
831 831
  enumeration_system_activity: System Activity
832 832
  permission_delete_issue_watchers: Delete watchers
833
  setting_commit_logtime_enabled: Enable time logging
834
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
835

  
833 836
  version_status_closed: closed
834 837
  version_status_locked: locked
835 838
  version_status_open: open
config/locales/uk.yml (working copy)
830 830
  field_active: Active
831 831
  enumeration_system_activity: System Activity
832 832
  permission_delete_issue_watchers: Delete watchers
833
  setting_commit_logtime_enabled: Enable time logging
834
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
835

  
833 836
  version_status_closed: closed
834 837
  version_status_locked: locked
835 838
  version_status_open: open
config/locales/da.yml (working copy)
854 854
  field_active: Active
855 855
  enumeration_system_activity: System Activity
856 856
  permission_delete_issue_watchers: Delete watchers
857
  setting_commit_logtime_enabled: Enable time logging
858
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
859

  
857 860
  version_status_closed: closed
858 861
  version_status_locked: locked
859 862
  version_status_open: open
config/locales/sr.yml (working copy)
849 849
  field_active: Active
850 850
  enumeration_system_activity: System Activity
851 851
  permission_delete_issue_watchers: Delete watchers
852
  setting_commit_logtime_enabled: Enable time logging
853
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
854

  
852 855
  version_status_closed: closed
853 856
  version_status_locked: locked
854 857
  version_status_open: open
config/locales/bg.yml (working copy)
828 828
  field_active: Active
829 829
  enumeration_system_activity: System Activity
830 830
  permission_delete_issue_watchers: Delete watchers
831
  setting_commit_logtime_enabled: Enable time logging
832
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
833

  
831 834
  version_status_closed: closed
832 835
  version_status_locked: locked
833 836
  version_status_open: open
config/locales/he.yml (working copy)
838 838
  field_active: Active
839 839
  enumeration_system_activity: System Activity
840 840
  permission_delete_issue_watchers: Delete watchers
841
  setting_commit_logtime_enabled: Enable time logging
842
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
843

  
841 844
  version_status_closed: closed
842 845
  version_status_locked: locked
843 846
  version_status_open: open
config/locales/fi.yml (working copy)
864 864
  field_active: Active
865 865
  enumeration_system_activity: System Activity
866 866
  permission_delete_issue_watchers: Delete watchers
867
  setting_commit_logtime_enabled: Enable time logging
868
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
869

  
867 870
  version_status_closed: closed
868 871
  version_status_locked: locked
869 872
  version_status_open: open
config/locales/bs.yml (working copy)
852 852
  field_active: Active
853 853
  enumeration_system_activity: System Activity
854 854
  permission_delete_issue_watchers: Delete watchers
855
  setting_commit_logtime_enabled: Enable time logging
856
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
857

  
855 858
  version_status_closed: closed
856 859
  version_status_locked: locked
857 860
  version_status_open: open
config/locales/fr.yml (working copy)
906 906
  text_journal_deleted: "{{label}} {{old}} supprimé"
907 907
  text_journal_added: "{{label}} {{value}} ajouté"
908 908
  enumeration_system_activity: Activité système
909
  setting_commit_logtime_enabled: Enable time logging
910
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
911

  
909 912
  label_board_sticky: Sticky
910 913
  label_board_locked: Verrouillé
config/locales/hr.yml (working copy)
353 353
  permission_view_issue_watchers: Pregledaj listu promatraca
354 354
  permission_add_issue_watchers: Dodaj promatrača
355 355
  permission_delete_issue_watchers: Delete watchers
356
  setting_commit_logtime_enabled: Enable time logging
357
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
358

  
356 359
  permission_log_time: Dnevnik utrošenog vremena 
357 360
  permission_view_time_entries: Pregledaj utrošeno vrijeme
358 361
  permission_edit_time_entries: Uredi vremenske dnevnike
config/locales/nl.yml (working copy)
816 816
  field_active: Active
817 817
  enumeration_system_activity: System Activity
818 818
  permission_delete_issue_watchers: Delete watchers
819
  setting_commit_logtime_enabled: Enable time logging
820
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
821

  
819 822
  version_status_closed: closed
820 823
  version_status_locked: locked
821 824
  version_status_open: open
config/locales/th.yml (working copy)
831 831
  field_active: Active
832 832
  enumeration_system_activity: System Activity
833 833
  permission_delete_issue_watchers: Delete watchers
834
  setting_commit_logtime_enabled: Enable time logging
835
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
836

  
834 837
  version_status_closed: closed
835 838
  version_status_locked: locked
836 839
  version_status_open: open
config/locales/no.yml (working copy)
829 829
  field_active: Active
830 830
  enumeration_system_activity: System Activity
831 831
  permission_delete_issue_watchers: Delete watchers
832
  setting_commit_logtime_enabled: Enable time logging
833
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
834

  
832 835
  version_status_closed: closed
833 836
  version_status_locked: locked
834 837
  version_status_open: open
config/locales/hu.yml (working copy)
859 859
  field_active: Active
860 860
  enumeration_system_activity: System Activity
861 861
  permission_delete_issue_watchers: Delete watchers
862
  setting_commit_logtime_enabled: Enable time logging
863
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
864

  
862 865
  version_status_closed: closed
863 866
  version_status_locked: locked
864 867
  version_status_open: open
config/locales/vi.yml (working copy)
893 893
  field_active: Active
894 894
  enumeration_system_activity: System Activity
895 895
  permission_delete_issue_watchers: Delete watchers
896
  setting_commit_logtime_enabled: Enable time logging
897
  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
898

  
896 899
  version_status_closed: closed
897 900
  version_status_locked: locked
898 901
  version_status_open: open
(11-11/13)