##// END OF EJS Templates
Don't update issues nor log time when importing old changesets (#4823)....
Jean-Philippe Lang -
r11969:7b1b605ae8e6
parent child
Show More
@@ -0,0 +1,9
1 class AddRepositoriesCreatedOn < ActiveRecord::Migration
2 def up
3 add_column :repositories, :created_on, :timestamp
4 end
5
6 def down
7 remove_column :repositories, :created_on
8 end
9 end
@@ -132,8 +132,11 class Changeset < ActiveRecord::Base
132 issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
132 issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
133 if issue
133 if issue
134 referenced_issues << issue
134 referenced_issues << issue
135 fix_issue(issue, action) if fix_keywords.include?(action)
135 # Don't update issues or log time when importing old commits
136 log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
136 unless repository.created_on && committed_on && committed_on < repository.created_on
137 fix_issue(issue, action) if fix_keywords.include?(action)
138 log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
139 end
137 end
140 end
138 end
141 end
139 end
142 end
@@ -8,6 +8,7 repositories_001:
8 login: ""
8 login: ""
9 type: Repository::Subversion
9 type: Repository::Subversion
10 is_default: true
10 is_default: true
11 created_on: 2006-07-19 19:04:21 +02:00
11 repositories_002:
12 repositories_002:
12 project_id: 2
13 project_id: 2
13 url: svn://localhost/test
14 url: svn://localhost/test
@@ -17,3 +18,4 repositories_002:
17 login: ""
18 login: ""
18 type: Repository::Subversion
19 type: Repository::Subversion
19 is_default: true
20 is_default: true
21 created_on: 2006-07-19 19:04:21 +02:00
@@ -254,6 +254,28 class ChangesetTest < ActiveSupport::TestCase
254 end
254 end
255 end
255 end
256
256
257 def test_old_commits_should_not_update_issues_nor_log_time
258 Setting.commit_ref_keywords = '*'
259 Setting.commit_update_keywords = {'fixes , closes' => {'status_id' => '5', 'done_ratio' => '90'}}
260 Setting.commit_logtime_enabled = '1'
261
262 repository = Project.find(1).repository
263 repository.created_on = Time.now
264 repository.save!
265
266 c = Changeset.new(:repository => repository,
267 :committed_on => 1.month.ago,
268 :comments => 'New commit (#2). Fixes #1 @1h',
269 :revision => '12345')
270 assert_no_difference 'TimeEntry.count' do
271 assert c.save
272 end
273 assert_equal [1, 2], c.issue_ids.sort
274 issue = Issue.find(1)
275 assert_equal 1, issue.status_id
276 assert_equal 0, issue.done_ratio
277 end
278
257 def test_text_tag_revision
279 def test_text_tag_revision
258 c = Changeset.new(:revision => '520')
280 c = Changeset.new(:revision => '520')
259 assert_equal 'r520', c.text_tag
281 assert_equal 'r520', c.text_tag
General Comments 0
You need to be logged in to leave comments. Login now