aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-07-10 12:02:31 +0200
committerFabrice Bellingard <bellingard@gmail.com>2012-07-12 10:33:31 +0200
commit616ed594427ad3d32be0547883a54a740374653f (patch)
treebe37aa67fdd63aa228eb8f329a02ca3212faaa4f /sonar-server
parent24d7c761a444ec9dd861a7ac7831d4d7946fb9f5 (diff)
downloadsonarqube-616ed594427ad3d32be0547883a54a740374653f.tar.gz
sonarqube-616ed594427ad3d32be0547883a54a740374653f.zip
SONAR-2496 Clean the version from snapshots when deleting a version
=> when deleting a version event, the 'version' property of a snapshot should be set to the version of the following snapshot to have a consistent and clean history of 'version' properties.
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
index cf5af3ed82d..de19cb7b14f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
@@ -342,7 +342,16 @@ class ProjectController < ApplicationController
snapshot=Snapshot.find(params[:sid])
not_found("Snapshot not found") unless snapshot
access_denied unless is_admin?(snapshot)
+
+ # We update all the related snapshots to have the same version as the next snapshot
+ next_snapshot = Snapshot.find(:first, :conditions => ['created_at>? and project_id=?', snapshot.created_at, snapshot.project_id], :order => 'created_at asc')
+ snapshots = find_project_snapshots(snapshot.id)
+ snapshots.each do |snapshot|
+ snapshot.version = next_snapshot.version
+ snapshot.save!
+ end
+ # and we delete the events
event = snapshot.event(EventCategory::KEY_VERSION)
old_version_name = event.name
events = find_events(event)