Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-11-19 13:59:31 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-11-19 19:52:12 +0300
commit9d926833c6efa8de39dcd82e8dd34550725a41fe (patch)
tree1436041f8c82307b25a2a8b5d18b2184567260a8 /lib/tasks
parent3b49851d13b544f2db410b8b81700ce97ff674f7 (diff)
Merge branch 'zj-rake-task-remove-faulty-deployment-refs' into 'master'
Fix faulty deployment refs In the 8.13 RC cycle, so before the release, there was a time in which references in git where stored by id instead of iid. This could be fixed by time, if the iid catches up with the id, it overwrites it. But in the mean time we have wrong refs in the folder. This commit fixes that. For all projects we have deployments we'll find the ones where the ref has a higher number than the iid is now and calls `#create_ref` on the corresponding deployment. Fixes gitlab-com/infrastructure#683 cc @ayufan One worry: I tested this locally, couldn't find a way to do automate this. See merge request !7352
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/cleanup.rake23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index b7cbdc6cd78..4a696a52b4d 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -91,5 +91,28 @@ namespace :gitlab do
puts "To block these users run this command with BLOCK=true".color(:yellow)
end
end
+
+ # This is a rake task which removes faulty refs. These refs where only
+ # created in the 8.13.RC cycle, and fixed in the stable builds which were
+ # released. So likely this should only be run once on gitlab.com
+ # Faulty refs are moved so they are kept around, else some features break.
+ desc 'GitLab | Cleanup | Remove faulty deployment refs'
+ task move_faulty_deployment_refs: :environment do
+ projects = Project.where(id: Deployment.select(:project_id).distinct)
+
+ projects.find_each do |project|
+ rugged = project.repository.rugged
+
+ max_iid = project.deployments.maximum(:iid)
+
+ rugged.references.each('refs/environments/**/*') do |ref|
+ id = ref.name.split('/').last.to_i
+ next unless id > max_iid
+
+ project.deployments.find(id).create_ref
+ rugged.references.delete(ref)
+ end
+ end
+ end
end
end