From 616ed594427ad3d32be0547883a54a740374653f Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Tue, 10 Jul 2012 12:02:31 +0200 Subject: [PATCH] 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. --- .../webapp/WEB-INF/app/controllers/project_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- 2.39.5