Compare commits

...

6 Commits

3 changed files with 21 additions and 1 deletions

View File

@ -30,9 +30,10 @@ class Admins::OrganizationsController < Admins::BaseController
end
def destroy
data_bank = @org.attributes.to_json
@org.destroy!
Admins::DeleteOrganizationService.call(@org.login)
UserAction.create(action_id: @org.id, action_type: "DestroyOrganization", user_id: current_user.id, :ip => request.remote_ip, data_bank: @org.attributes.to_json)
UserAction.create(action_id: @org.id, action_type: "DestroyOrganization", user_id: current_user.id, :ip => request.remote_ip, data_bank: data_bank)
render_delete_success
end

View File

@ -383,6 +383,24 @@ class ProjectsController < ApplicationController
end
end
def clone_detection
forge_url = "#{Rails.application.config_for(:configuration)['platform_url']}"
target_dir = "2-#{SecureRandom.hex(6)}"
source_url = "#{forge_url}/#{@project.owner.name}/#{@project.identifier}.git"
source_dir = "#{@project.id}-#{SecureRandom.hex(6)}"
clone_dir = File.join(Rails.root, "public", "clone_detection")
system("cd #{clone_dir} && git clone #{params[:target_url]} #{target_dir}")
system("cd #{clone_dir} && git clone #{source_url} #{source_dir}")
system("cd /var/www/NiCad-6.2 && ./nicad6cross functions java /var/www/forgeplus/public/clone_detection/#{source_dir} /var/www/forgeplus/public/clone_detection/#{target_dir}")
view_url = "#{forge_url}/#{source_dir}_functions-blind-crossclones/#{source_dir}_functions-blind-crossclones-0.30-classes-withsource.html"
system("rm -rf /var/www/forgeplus/public/clone_detection/#{source_dir}")
system("rm -rf /var/www/forgeplus/public/clone_detection/#{target_dir}")
render_ok({ view_url: view_url })
rescue
Rails.logger.info("clone_detection...............error#{forge_url},#{source_url}")
system("rm -rf /var/www/forgeplus/public/clone_detection/#{source_dir}")
system("rm -rf /var/www/forgeplus/public/clone_detection/#{target_dir}")
end
private

View File

@ -548,6 +548,7 @@ Rails.application.routes.draw do
get :forks, to: 'projects#fork_users'
match :about, :via => [:get, :put, :post]
post :quit
post :clone_detection
end
end