Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ManageIQ/all.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env ruby
ENV['RAILS_ENV'] = 'development'

require '../manageiq/config/environment'

#in miq-ui-classic ls | grep "controller.rb" | cut -d '.' -f 1
all_controllers = `ls app/controllers/ | grep "controller.rb" | cut -d '.' -f1`.split("\n")

whitelist = []

all_controllers.each do |controller_name|
break if controller_name == "oauth_sessions_controller"
controller = controller_name.classify.constantize
buttons = controller.constants.select{|x| x.to_s.include?("ALLOWED_ACTIONS")}
break unless buttons.present?
buttons.each do |button|
whitelist.concat(controller.const_get(button).keys)
end
end
whitelist.sort.uniq.each { |item| puts item }
42 changes: 42 additions & 0 deletions ManageIQ/dead_methods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#all temp files
ROUTES=`mktemp`
ALLOWEDMETHODS=`mktemp`
OLD=`mktemp`
NEW=`mktemp`

#in miq get routes
bundle exec rake routes | ag "\s#*([\S]+)$" -o | ag '(?<=#).*' -o > "$ROUTES"
echo "routes DONE"

#in miq-ui
cd ..
cd manageiq-ui-classic
echo "moved to miq-ui-classic"

if [[ -n $0 ]]; then
git checkout $0
bin/update
fi
ruby /Users/zita/Desktop/all.rb > "$ALLOWEDMETHODS"
Copy link
Owner

@himdel himdel May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/Users/zita/Desktop/ 🙀

dirname "$0"

should work :) ($0 is the current script)

sed -i "" '/^\*/ d' "$ALLOWEDMETHODS"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me, this always fails with

sed: can't read /^\*/ d: No such file or directory

I must be doing something wrong

Copy link
Owner

@himdel himdel May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac vs Linux:

in macs, -i takes a required parameter (which extension to add to the backup file)
on linux, -i takes an optional parameter, and space means it's not there (so the "" becomes the regex, and the next param a filename)

=> sed -i" " ... should work on both


echo "extra methods DONE"

debride --rails app/ --whitelist "$ROUTES" "$ALLOWEDMETHODS" | cut -d ":" -f1 > "$OLD"

echo "old possibly dead methods DONE"

if [[ -n $1 ]]; then
git checkout $1
bin/update
ruby /Users/zita/Desktop/all.rb > "$ALLOWEDMETHODS"
sed -i "" '/^\*/ d' "$ALLOWEDMETHODS"
debride --rails app/ --whitelist "$ROUTES" "$ALLOWEDMETHODS" | cut -d ":" -f1 > "$NEW"
echo "ALL DEFFERENCES"
diff -Naur "$OLD" "$NEW"
else
cat "$OLD" | while read line; do
echo "$line"
done
fi