logtime_redmine_0.9.2_v2.3.patch

Katy A, 2010-05-25 01:45

Download (22.7 KB)

View differences:

app/models/changeset.rb (revision 18511)
88 88
    return if kw_regexp.blank?
89 89
    
90 90
    referenced_issues = []
91
    
91
    log_time = []
92

  
93
    logger.debug "Changeset comment: #{comments}" if logger && logger.debug?
94

  
92 95
    if ref_keywords.delete('*')
93 96
      # find any issue ID in the comments
94 97
      target_issue_ids = []
95
      comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
98
      comments.scan(%r{([\s\(\[,-]|^)#(\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?(?=[[:punct:]]|\s|<|$)}).each do |m|
99
        target_issue_ids << m[1]
100
        log_time << [m[1], (m[2] != nil ? m[2].scan(/(\d+[.]\d+|(\d+[hm]\s?){1,2})/)[0][0] : 0)]
101
      end
102

  
96 103
      referenced_issues += find_referenced_issues_by_id(target_issue_ids)
97 104
    end
98 105
    
99
    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
106
    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+((([\s,;&]*([^@]|#?)\\d+)([\s]*@(\\d+[.]\\d+|(\\d+[hm]\s?){1,2}))?)+)", Regexp::IGNORECASE)).each do |match|
100 107
      action = match[0]
101
      target_issue_ids = match[1].scan(/\d+/)
108
 
109
      target_issues_with_log = match[1].scan(/([\s,;&]*([^@]|#?)\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?/)
110
      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) ] }
111

  
112
      log_time += target_issues_with_log
113
 
114
      target_issue_ids = target_issues_with_log.collect {|x| x[0]}
102 115
      target_issues = find_referenced_issues_by_id(target_issue_ids)
116

  
103 117
      if fix_status && fix_keywords.include?(action.downcase)
104 118
        # update status of issues
105
        logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
119
        logger.debug "Issues fixed by changeset #{self.revision}: #{target_issue_ids.join(', ')}." if logger && logger.debug?
106 120
        target_issues.each do |issue|
107 121
          # the issue may have been updated by the closure of another one (eg. duplicate)
108 122
          issue.reload
......
120 134
          issue.save
121 135
        end
122 136
      end
137
      
123 138
      referenced_issues += target_issues
124 139
    end
140

  
141
    if Setting.commit_logtime_enabled?
142
      log_time.uniq.each do |issue_wl|
143
        next if issue_wl[1] == nil || issue_wl[1] == 0
144

  
145
        issue_id = issue_wl[0]
146
        issue_hours = issue_wl[1]
147

  
148
        match = issue_hours.match(/\d+[.]\d+/)
149

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

  
156
          hours = (hours == nil ? 0 : hours.to_i)
157
          minutes = (minutes == nil ? 0 : minutes.to_i)
158

  
159
          issue_hours = ((hours.to_f + minutes.to_f / 60.0) * 100.0).round / 100.0
160
        end
161

  
162
        next if issue_hours.to_f <= 0
163

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

  
166
        issue = Issue.find_by_id(issue_id)
167

  
168
        activity = TimeEntryActivity.default
169
        if activity == nil
170
          activity = TimeEntryActivity.find(:first)
171
        end
172

  
173
        next if activity == nil || issue == nil || user == nil
174

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

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

  
188
	timeentry.save
189
      end
190
    end
125 191
    
126 192
    self.issues = referenced_issues.uniq
127 193
  end
app/views/settings/_repositories.rhtml (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
899 899
  enumeration_doc_categories: Document categories
900 900
  enumeration_activities: Activities (time tracking)
901 901
  enumeration_system_activity: System Activity
902
  setting_commit_logtime_enabled: Enable time logging
903
  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)"
902 904

  
905

  
config/locales/gl.yml (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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/nl.yml (revision 18511)
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/hr.yml (revision 18511)
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/th.yml (revision 18511)
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 (revision 18511)
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 (revision 18511)
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 (revision 18511)
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